本文介绍了如何一次在本地通知中将日期数组设置为fireDate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
实际上,在我的应用中,我在不同的时间启动了两个以上的计时器.在特定的时间间隔后,我希望触发通知.当应用程序在前台但不在后台时,它工作正常.我该如何解决?
Actually in my app I'm starting more than two timers at different times. After certain time intervals I want notifications to fire. It's working fine when the app is on foreground but not in the background. How can I solve this?
请帮助.谢谢!
推荐答案您需要执行以下操作...
You need to do following...
您需要打开后台模式.
在AppDelegate中,添加此代码以在后台运行应用程序
In AppDelegate, Add this code to run app in background
创建属性
@property (nonatomic, assign) UIBackgroundTaskIdentifier backgroundTask;然后执行以下操作...
and then do following...
- (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"); } }希望它能对您有所帮助.
I hope it will help you.
更多推荐
如何一次在本地通知中将日期数组设置为fireDate
发布评论