简体   繁体   English

如何暂时禁用我的iPhone应用程序安排的所有本地通知?

[英]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.

相关问题 如何在本地/远程通知上闪烁iphone的手电筒 - how can I blink flashlight of iphone on local / Remote notification 安排并显示本地通知后,启动iPhone应用程序需要什么代码? - What code is required to launch an iPhone app after a local notification has been scheduled and displayed? 如何从 Apple App Store 中暂时删除我的应用程序? - How can I remove my app temporarily from the Apple App Store? 如何在我的iPhone应用程序中禁用多点触控功能? - How can I disable the multitouch capabilities in my iPhone application? iPhone - 暂时禁用键盘 - iPhone - temporarily disable keyboard iPhone应用程序在本地通知时崩溃 - iPhone app crashing on local notification 删除应用程序时如何清除所有计划的本地通知 - How to clear all scheduled local notifications when deleting the app 如何在越狱的iPhone上测试iPhone应用程序? - How can I test an iPhone app on my iPhone that is Jailbroken? 我的应用程序可以知道我是否通过通知中心在iPhone上收到短信 - can my app knows that I received a sms on my iphone using Notification Center iPhone/iOS:如何获取我的应用本地化的所有语言的本地化字符串列表? - iPhone/iOS: How can I get a list of localized strings in all the languages my app is localized in?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM