[英]How can I temporarily disable all local notification scheduled by my iPhone app?
Is there any method to temporarily disable all local notifications created by an iPhone app? 有什么方法可以暂时禁用iPhone应用程序创建的所有本地通知? I need to re enable them all with respect to a condition.
我需要根据条件重新启用它们。 my requirement is if the user turned off the notification button on my app , then no more notifications is shown.If he turned it on then all notifications should be shown.
我的要求是,如果用户关闭了我应用程序上的通知按钮,则不会再显示任何通知。如果他将其打开,则应显示所有通知。 Any idea?
任何想法?
You can get all scheduled notifications and save them in shared preferences for example. 例如,您可以获取所有计划的通知并将其保存在共享首选项中。
[[UIApplication sharedApplication] scheduledLocalNotifications];
Then cancel all notifications: 然后取消所有通知:
- (void)cancelLocalNotification:(UILocalNotification *)notification
If user activate notifications again, you can reschedule them again. 如果用户再次激活通知,则可以重新安排它们的时间。
您可以使用“ cancelAllLocalNotifications”方法,当用户将其打开时,可以再次为其设置所有通知。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.