How make iOS app running on background Every one minute in Swift?

前端 未结 3 1397
[愿得一人]
[愿得一人] 2021-01-29 10:01

I want to make an app that makes HTTP request to a website periodically. The app has to run in the background, but can wake up or show a notification, depending on a response of

3条回答
  •  别那么骄傲
    2021-01-29 10:41

    The only way to do that is using a Silent push notification(see the Docs HERE and HERE), it will wake up your app on background and give you a chance to execute some code for a bit of time. But unfortunately it wont work with local notification, need to be a push notification.

    Obs: Note that your time is limited to execute the background task, as the doc says

    Your app has 30 seconds to perform any tasks and call the provided completion handler

    And if you send too much push, the iOS can punish your application by giving it a small priority to execute your task, or even simply don't executing it

提交回复
热议问题