在带有iOS 7和更高版本的设备上,我们需要我们的应用程序来使用后台获取iOS API。我们需要这样做,因为我们的服务器还不能实现推送通知。为此,我做了以下工作:
意见:-
我们可能做错什么了吗?请与背景提取任务API (如果有的话)分享您的经验。
发布于 2015-04-23 07:34:56
系统根据用户的行为唤醒应用程序,目的是在用户启动应用程序之前触发背景提取。例如,如果用户总是在下午1点使用应用程序,系统就会学习和调整,在使用期间之前执行获取。
(http://www.objc.io/issue-5/multitasking.html)
完全可以预期,在背景取取之间会看到10-15分钟的间隔。
您可以通过选择Debug
-> Simulate Background Fetch
从Xcode的菜单栏(同时调试)触发后台提取。
发布于 2014-05-26 02:15:58
使用以下代码在app后台状态下执行某些代码:
UIApplication *app = [UIApplication sharedApplication];
task = [app beginBackgroundTaskWithExpirationHandler:^{
[app endBackgroundTask:task];
task = UIBackgroundTaskInvalid;
}];
// Start the long-running task and return immediately.
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
// Do the work associated with the task.
if (connectedToNetwork) {
// do work son...
}
[app endBackgroundTask:task];
task = UIBackgroundTaskInvalid;
});
https://stackoverflow.com/questions/23866941
复制相似问题