Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Background fetch is not working after killing the app

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

like image 732
Meryem Uysal Avatar asked Feb 18 '16 10:02

Meryem Uysal


People also ask

Will iOS terminate the app running in background after a specific time?

No, there is no specific time defined for this.

What is background fetch in iOS?

Background fetch is a new mode that lets your app appear always up-to-date with the latest information while minimizing the impact on battery. You could download feeds within fixed time intervals with this capability. To get started: 1- Check Background Fetch in capabilities screen in Xcode.

Is it possible to use background fetch in iOS native app?

I have created an iOS native app using Swift 5.0, which internally fetch data from the server using background fetch feature of iOS if the App is running in background mode. Background fetching is working properly in Simulator and http request reaches in the server. But background fetches not at all working in the real device (iPad Air & iOS 12.2).

How are background fetch operations throttled?

Background Fetch operations are throttled the same way many background operations are, and whether the task will be run as scheduled, and what that schedule will be is based on various aspects and states on the device. In the context of Background Fetch, one important point to understand is what the “minimum fetch interval” is.

What does 1 hour background fetch interval mean?

Actually, what this means is that the background fetch will not happen any sooner than what you specify. So, if you specify your interval as 1 hour, we are only guaranteeing that the fetch will not happen any sooner than 1 hour. Outside of that the system will take this interval as a general suggestion for scheduling the fetches.


2 Answers

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.

like image 126
Alex Avatar answered Sep 20 '22 23:09

Alex


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

like image 37
Bhushan Rana Avatar answered Sep 17 '22 23:09

Bhushan Rana