Will iOS launch my app into the background if it was force-quit by the user?

后端 未结 7 775
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-22 00:46

I am triggering a background fetch by using the content-available flag on a push notification. I have the fetch and remote-notification

7条回答
  •  不知归路
    2020-11-22 01:20

    UPDATE2:

    You can achieve this using the new PushKit framework, introduced in iOS 8. Though PushKit is used for VoIP. So your usage should be for VoIP related otherwise there is risk of app rejection. (See this answer).


    UDPDATE1:

    The documentation has been clarified for iOS8. The documentation can be read here. Here is a relevant excerpt:

    Use this method to process incoming remote notifications for your app. Unlike the application:didReceiveRemoteNotification: method, which is called only when your app is running in the foreground, the system calls this method when your app is running in the foreground or background. In addition, if you enabled the remote notifications background mode, the system launches your app (or wakes it from the suspended state) and puts it in the background state when a push notification arrives. However, the system does not automatically launch your app if the user has force-quit it. In that situation, the user must relaunch your app or restart the device before the system attempts to launch your app automatically again.


    Although this was not made clear by the WWDC video, a quick search on the developer forums turned this up:

    https://devforums.apple.com/message/873265#873265 (login required)

    Also keep in mind that if you kill your app from the app switcher (i.e. swiping up to kill the app) then the OS will never relaunch the app regardless of push notification or background fetch. In this case the user has to manually relaunch the app once and then from that point forward the background activities will be invoked. -pmarcos

    That post was by an Apple employee so I think i can trust that this information is correct.

    So it looks like when the app is killed from the app switcher (by swiping up), the app will never be launched, even for scheduled background fetches.

提交回复
热议问题