-2
我在Capabilities(如「後臺提取」)中添加長時間運行的任務並添加此代碼。它會好嗎,我會在所有背景應用程序生活中更新?ios7中的長時間運行任務
- (void)applicationDidEnterBackground:(UIApplication *)application
{
UIApplication *app = [UIApplication sharedApplication];
UIBackgroundTaskIdentifier bgTask = 0;
bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
[app endBackgroundTask:bgTask];
}];
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:5 target:self selector:@selector(backgroundUpdate) userInfo:nil repeats:YES];
[timer fire];
}
可能重複的[如何在ios7中運行後臺進程](http://stackoverflow.com/questions/22756480/how-to-run-process-in-background-in-ios7) –
重複的問題的答案是不是很好,它誤導IMO – Gruntcakes