实际上,在我的应用程序中,我在不同时间启动了两个以上的计时器。在特定的时间间隔后,我希望触发通知。当应用程序在前台但不在后台时,它工作正常。我该如何解决这个问题?
请帮忙。谢谢!
你需要做以下...
您需要打开后台模式。
在 AppDelegate 中,添加此代码以在后台运行应用程序
创建属性
@property (nonatomic, assign) UIBackgroundTaskIdentifier backgroundTask;
然后做以下...
- (void)applicationDidEnterBackground:(UIApplication *)application {
self.backgroundTask = [application beginBackgroundTaskWithExpirationHandler:^{
DLOG(@"End of tolerate time. Application should be suspended now if we do not ask more 'tolerance'");
}];
if (self.backgroundTask == UIBackgroundTaskInvalid) {
DLOG(@"This application does not support background mode");
} else {
//if application supports background mode, we'll see this log.
DLOG(@"Application will continue to run in background");
}
}
我希望它会帮助你。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句