简体   繁体   English

有关iOS上的本地通知和推送通知的问题

[英]questions about local and push notifications on ios

I can't find sure answers on some questions I had about push/local notifications. 对于某些有关推送/本地通知的问题,我找不到确切的答案。

  1. Does disabling push notifications also disable local notifications? 禁用推送通知是否还会禁用本地通知?

  2. Can I detect if the user has disabled push notifications for my application? 是否可以检测用户是否已禁用应用程序的推送通知? If so, how do I do that? 如果是这样,我该怎么做? EDIT: Just as I submitted the question, I found: Determine on iPhone if user has enabled push notifications That's the recommended way? 编辑:就在我提交问题时,我发现: 确定在iPhone上用户是否已启用推送通知。这是推荐的方法吗?

Thanks! 谢谢!

  1. Disabling push notifications does not disable local notifications, they are independent of each other. 禁用推送通知不会禁用本地通知,因为它们彼此独立。
  2. You can check that way, that will indeed work. 您可以检查这种方式,那确实可以。 Another alternative is to set a persistent flag in your AppDelegate class. 另一种选择是在AppDelegate类中设置一个持久标志。

     - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"registeredForPush"]; } - (void) application: (UIApplication *) application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"registeredForPush"]; } 

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

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