0

How can I create an API call, and when got the response a local push every 15 minutes, when the app is closed or in the background?

I tried BGTaskScheduler but it not triggered 15 minutes. I do not what is the logic, but triggered sometime in a 20 minutes or longer time. Need some advice or an other object or class what I can use it

  • 2
    There is no guaranteed way to do anything in the background. You can research “Background Modes” and see if your app meets any of the approved modes and use that setup – lorem ipsum Aug 31 '23 at 11:46
  • Please provide enough code so others can better understand or reproduce the problem. – Community Aug 31 '23 at 13:26
  • See [Choosing Background Strategies for Your App](https://developer.apple.com/documentation/backgroundtasks/choosing_background_strategies_for_your_app?language=objc) and watch WWDC 2020 [Background execution demystified](https://developer.apple.com/videos/play/wwdc2020/10063/). But this polling in the background at a regular intervals is simply not permitted (iOS does this to avoid eating up mobile device batteries and data plans). But polling strategies should should generally be avoided, regardless. – Rob Aug 31 '23 at 20:40
  • Background fetch is good for trying to make sure that the app is more likely to have current data the next time the user launches the app (scheduled on the basis of historical usage patterns and run at the sole discretion of the OS). Significant change service is good if you want to do something given updated geolocation info. If you’re trying to inform the user of some time sensitive event identified by your backend, then the *server* should send a remote push notification when that happens rather than the client constantly polling every 15 minutes. – Rob Aug 31 '23 at 20:40
  • If you describe the business problem you are trying to solve, we would be able to better advise you on the practical, permitted, solutions. – Rob Aug 31 '23 at 20:48

0 Answers0