katzer / cordova-plugin-background-mode

Keep app running in background
Apache License 2.0
1.38k stars 1.02k forks source link

How to keep ios app running in background? #482

Open cetcseni opened 4 years ago

cetcseni commented 4 years ago

I have an Ionic 3 app that run some tasks periodically (say every hour). On android works fine. However, on ios, when app is in background, tasks are not done until app resume. Is there a way to keep ios app running? Local notifications are not a solution because it needs user action. I have the latest version of this plugin and I installed cordova-plugin-background-fetch, but it is not exactly what I want because background-fetch execution is quite random. I also read that ios suspends app works about 3 minutes after going to background. Any help will be appreciated.

HassanMehdi17 commented 4 years ago

did you ever get any progress with this?

cetcseni commented 4 years ago

No. Maybe there isn´t a solution, unless Apple do something.

ghenry22 commented 4 years ago

You can't have infinite background run time like that, it just won't work.

There are some specific exceptions for apps that play audio and similar things in the background. Even with those though, when your audio stops playing and the app is idle for a period of time it will still be suspended by the OS.

You can use push notifications to trigger the app to launch and do something in the background. I believe that you can do a silent push notification which will start the app up in the background (or restart if needed) run some logic and then go back to sleep. This is probably the closest you will get to what you want.

cetcseni commented 4 years ago

I'm thinking in a solution like that. Thank you for your help.

Gaven Henry notifications@github.com escreveu no dia quinta, 2/04/2020 à(s) 06:13:

You can't have infinite background run time like that, it just won't work.

There are some specific exceptions for apps that play audio and similar things in the background. Even with those though, when your audio stops playing and the app is idle for a period of time it will still be suspended by the OS.

You can use push notifications to trigger the app to launch and do something in the background. I believe that you can do a silent push notification which will start the app up in the background (or restart if needed) run some logic and then go back to sleep. This is probably the closest you will get to what you want.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/katzer/cordova-plugin-background-mode/issues/482#issuecomment-607625341, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANZWF5M23HDTRI374MSJT2DRKQNH7ANCNFSM4JQA2MVA .

robotics131983 commented 3 years ago

Did the silent push notifications work? What was the logic for IOS. I am experiencing this. We need have communications sent out to appS to take action on random basis, maybe one hour maybe one day, etc. Will this work if sent right before the communications