My iphone app background process terminates after 10 mins

后端 未结 3 957
栀梦
栀梦 2021-01-29 16:41

I have been facing a issue that my app doesnt run background for more than 10 mins , I have implemented background task which will fetch notifications instantly.

my appl

相关标签:
3条回答
  • 2021-01-29 16:48

    If I'm not mistaken or not misunderstanding your question, this is expected behaviour. Background tasks are time limited so that one app doesn't run indefinitely and consume resources like battery power and cellular data.

    There are different types of background modes, some perform a set task and suspend when complete or timed out, others run periodically.

    You're likely looking to implement background fetch, wherein the OS will periodically wake your app and allow it to check for new content and perform a quick data fetch to get the latest data from your server.

    Background fetch can be triggered by a push notification that has the "content-available" flag set in its payload. The OS will be selective in scheduling background fetches for apps and will often coalesce them together to be more efficient. The OS will also learn when users run your app and try to schedule background fetches before the time a user opens your app so that the latest data is available.

    0 讨论(0)
  • 2021-01-29 16:54

    You should use Push Notifications instead fetching them every 5 minutes. It's will work on the fly and will not drain the battery.

    0 讨论(0)
  • 2021-01-29 16:58

    This is normal. You are not supposed to run timers in the background. On iOS7 and above, you should be using background fetch mode to fetch data (or do it properly, using push).

    Read here for more information on iOS7 background modes.

    Note, that on iOS7 and above, background tasks are even shorter (~30 seconds) rather than 10 minutes, so you are even less encouraged to use that API for such work.

    0 讨论(0)
提交回复
热议问题