iOS 7 Background Fetch When the App is Not Running

后端 未结 1 1161
后悔当初
后悔当初 2021-02-02 03:12

I\'ve written a simple application in order to test and monitor how the background fetch feature works in iOS7.

First of all, I\'ve set UIBackgroundMode options in my In

相关标签:
1条回答
  • 2021-02-02 03:42

    Edit 2: Note that if a user kills the app from the app switcher, the background fetch will never happen again. This is working as Apple intended. See the related "Understanding When Your App Gets Launched into the Background" docs for details:

    In most cases, the system does not relaunch apps after they are force quit by the user. One exception is location apps, which in iOS 8 and later are relaunched after being force quit by the user.

    And an old developer forums post (the link unfortunately no longer exists)...

    "If you kill an app from the multitasking UI, the system will never automatically launch the app again. The logic here is that, if the user has killed your app, they probably want it to stay dead."

    You could make a simple GET request, eg: "http://dev.example.org/?ping=1" to your web server then grep the access.log on the web server for "?ping=1"

    Edit: Another method to test the app being launched in the background (eg: without being able to double tap the home button and switch to it) is by creating a background-only scheme. Go to Product -> Scheme -> Manage Schemes and then duplicate your default scheme.

    scheme settings

    Then edit the new scheme and click the Options tab and check "Launch due to a background fetch event" - when you run your app it'll be launched directly into the background, as it would through normal use.

    launch with background fetch

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