Запретить закрытие процесса браузера на мобильном телефоне ⇐ IOS
-
Anonymous
Запретить закрытие процесса браузера на мобильном телефоне
I'm trying to build a timer PWA (mostly for mobile devices), which notifies the user when a certain amount of time has passed. (The users will know this and want it to happen - so asking for permission wouldn't be a problem.)
This works fine was long as the users actually stays on the page, keeps the browser open and doesn't lock the screen.
With the Wakelock API I can prevent the screen from locking itself - if we're on a device and in a browser which support that. (Sadly, many don't.) The NoSleep.js library adds support for more devices by playing a video which the user doesn't see. So that's something.
However, if the user actively enables the lockscreen (which many do instinctively when, say, putting their phones into their pockets) the process will be paused by iOS or Android after a while. Which means, that the notification will be delayed until the user opens the browser again. This may be much later, thereby defeating the whole purpose of this app.
If I were developing a native app, I could use something like a matching UIBackgroundMode or Background Fetch on iOS or a WorkManager on Android. However, building this as a native app would not have the advantages of a PWA, such as that no installation is required or that we can update the app at will.
From what I understand, many (all?) browser makers don't seem to want websites to be able to run in the background. Is there a way to build this kind of PWA nevertheless? Or would I have to switch to building a native app? (Which may still have fight the OS, as explained on pages such as dontkillmyapp.com.)
Источник: https://stackoverflow.com/questions/659 ... -on-mobile
I'm trying to build a timer PWA (mostly for mobile devices), which notifies the user when a certain amount of time has passed. (The users will know this and want it to happen - so asking for permission wouldn't be a problem.)
This works fine was long as the users actually stays on the page, keeps the browser open and doesn't lock the screen.
With the Wakelock API I can prevent the screen from locking itself - if we're on a device and in a browser which support that. (Sadly, many don't.) The NoSleep.js library adds support for more devices by playing a video which the user doesn't see. So that's something.
However, if the user actively enables the lockscreen (which many do instinctively when, say, putting their phones into their pockets) the process will be paused by iOS or Android after a while. Which means, that the notification will be delayed until the user opens the browser again. This may be much later, thereby defeating the whole purpose of this app.
If I were developing a native app, I could use something like a matching UIBackgroundMode or Background Fetch on iOS or a WorkManager on Android. However, building this as a native app would not have the advantages of a PWA, such as that no installation is required or that we can update the app at will.
From what I understand, many (all?) browser makers don't seem to want websites to be able to run in the background. Is there a way to build this kind of PWA nevertheless? Or would I have to switch to building a native app? (Which may still have fight the OS, as explained on pages such as dontkillmyapp.com.)
Источник: https://stackoverflow.com/questions/659 ... -on-mobile
Мобильная версия