更新时间:2023-01-24 08:50:03
iOS will allow you 3 minutes of execution in background.
如果要保持运行状态,可以使用各种解决方法",但不能找到一个稳定的解决方案.您可以启动后台任务,然后对其进行管理
If you want to keep running there are various "workarounds" but not a stable solution.You can initiate background tasks and then manage them
-(void)applicationDidEnterBackground:(UIApplication *)application
{
UIApplication *app = [UIApplication sharedApplication];
UIBackgroundTaskIdentifier bgTask = 0;
backgroundTimer = [NSTimer scheduledTimerWithTimeInterval:10 target:self selector:@selector(backgroundTask) userInfo:nil repeats:YES];
bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
[app endBackgroundTask:bgTask];
}];
}