How to do some task in background after kill the a

2019-09-19 05:59发布

问题:

i am doing one application.In that one task is running in background every time.My problem is,if i kill the application then that task also stopped.But i want to run that task after application killed by user.How to do this one.

回答1:

There is no way to run any kind of processes in the background after user kills the application. See what Viber does for their app.

So you can give a notice to user not to quit the app, but you would have to give them a valid reason. And if your app is not GPS or Music app your app will not be active in the background and you all your processes will be suspended by the OS to save battery life.



回答2:

Apple doesn't allow you to background execution after user kill the apps. If your app in background and you want to perform some execution. you can do this. Using background service of apple. but iOS will kill the app after 3 mins.(Some geeks said you get 10 mins. but i try to implement it, i found that 3 mins is max limit from apple) but apple allows longer run for app in background in only special cases. Explore this for better understanding



回答3:

After killing the application we can't run the background task programatically. But we can trigger the background task using push notification. For that some time limit(30sec) is there to finish the task. Check

-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler this method..

Link: apple documentation