简体   繁体   English

用户可以禁用LocalNotifications吗

[英]Can LocalNotifications be disabled by the user

I want to use UILocalNotifications as a background timer for an app. 我想将UILocalNotifications用作应用程序的后台计时器。 Can this notifications be disabled by the user like remote notifications? 用户可以像远程通知一样禁用此通知吗? If the user disables remote notifications for the app, are the local notifications disabled to? 如果用户禁用了应用程序的远程通知,本地通知是否被禁用?

I finally wrote a test app to test this feature. 我终于写了一个测试应用程序来测试这个功能。 The settings of "Notification" has no effect on local notifications. “通知”的设置对本地通知无效。 They will appear also while "Notifications" are completely disabled. 当“通知”被完全禁用时,它们也会出现。

If you look closely at that page of Settings.app, you'll see it's called "Notification". 如果您仔细查看Settings.app的该页面,您会看到它称为“通知”。 No mention of local/remote. 没有提及本地/远程。 The two kinds of notification are actually designed to be indistinguishable to the user. 实际上,这两种通知的设计对用户来说是无法区分的。 So your settings in the Settings.app affect both types. 因此,您在Settings.app中的设置会同时影响这两种类型。

That said, I also think it's polite to give people the option of disabling them in my app itself. 也就是说,我也认为让人们选择在我的应用程序本身中禁用他们是有礼貌的。 If a person opts out in the settings screen of my app, I either cancel all upcoming local notifications, or hit my server with some flag turning off remote notifications for this user. 如果某人在我的应用程序的设置屏幕中选择退出,则我要么取消所有即将到来的本地通知,要么用一些标志关闭我的服务器,以关闭该用户的远程通知。 I also store that preference in NSUserDefaults so it can inform my notification-scheduling and apn-token-registering behavior on next launch. 我还将该首选项存储在NSUserDefaults中,以便它可以在下次启动时通知我的通知计划和apn令牌注册行为。

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

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