如何一次在本地通知中将日期数组设置为fireDate

编程入门 行业动态 更新时间:2024-10-25 02:18:45
本文介绍了如何一次在本地通知中将日期数组设置为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

本文发布于:2023-11-27 07:08:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1637080.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数组   设置为   中将   日期   通知

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!