How to do some task in background after kill the application

放肆的年华 提交于 2019-12-25 03:15:11

问题


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



来源:https://stackoverflow.com/questions/28272612/how-to-do-some-task-in-background-after-kill-the-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!