简体   繁体   English

在iOS中保存本地通知

[英]Save Local Notification in ios

How to save the local notification? 如何保存本地通知? I want to use the local notification fire date again to schedule local notification. 我想再次使用本地通知生效日期来安排本地通知。

You should use UILocalNotification 您应该使用UILocalNotification

Please check out documentation: https://developer.apple.com/library/ios/documentation/iPhone/Reference/UILocalNotification_Class/ 请查看文档: https : //developer.apple.com/library/ios/documentation/iPhone/Reference/UILocalNotification_Class/

It look something like: 它看起来像:

UILocalNotification *localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = dateTime;
localNotification.alertBody = [NSString stringWithFormat:@"Alert Fired at %@", dateTime];
localNotification.soundName = UILocalNotificationDefaultSoundName;
localNotification.applicationIconBadgeNumber = 1;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];

About notification re-schedule cycle: 关于通知重新安排周期:

Firing the notification is not enough to show up another one. 发出通知不足以显示另一个通知。 Your app won't be launch except if user tap the notification. 除非用户点击通知,否则不会启动您的应用程序。 You could pre-schedule a notification for every day or week for the next month and unschedule them if user open one. 您可以为下个月的每天或每周预先安排一个通知,如果用户打开一个通知,则可以取消安排。 Depending of your need you could also fire a remote notification with a content-available key which will launch your app in background and allow you to reschedule a new local notification. 根据您的需要,您还可以使用content-available键触发remote notification ,该remote notification将在后台启动您的应用,并允许您重新安排新的本地通知。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM