Background fetch is not working after killing the app
Asked Answered
R

2

12

I'm trying to get data from url with background fetch. My func tries to get data and if there is a new data, it sends local notification. Background fetch works after about 10 - 20 minutes when i minimize the app. But when i kill the app (double click home button and close app) it doesn't work. I waited about 1 hour but it didn't work. I am using background service in android and it is working successfully. Is there any way to get data from url and send local notification when app is closed? I am using Xcode 6 and swift 1.2

Reifel answered 18/2, 2016 at 10:22 Comment(3)
Hope this help you raywenderlich.com/92428/background-modes-ios-swift-tutorialTaima
I think the only way to achieve this is to use PushKit, there is a question about it here.Dysphemism
Use Push Notification to re-start terminated app.Geotropism
R
25

The Background Fetching will NOT happen in your app after the user has killed it in the multitasking UI. This is by design.

Take a look at Apple's documentation that mentions:

Apps that support background execution may be relaunched by the system to handle incoming events. If an app is terminated for any reason other than the user force quitting it, the system launches the app...

and

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. In other cases, though, the user must launch the app explicitly or reboot the device before the app can be launched automatically into the background by the system.

As you noticed in the documentation, there's only 1 exception when the app will be relaunched if it was force killed: by using location services. Unfortunately this does not apply to you.

Also, you cannot detect if the app was force killed by the user. Check this StackOverflow answer.

Retardant answered 18/2, 2016 at 10:47 Comment(2)
is there any possibilities to execute code after app termination in ios 10 swift 3.0 ???Michelle
@PatelJigar No. iOS 10 behaves the same as iOS 9 and 8 in this manner. Again, this is by design.Retardant
S
4

The Background Fetching will NOT Update in your app after the user has killed app from background. it is not Possible

Sihon answered 18/2, 2016 at 10:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.