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

标签 iphone ios push-notification apple-push-notifications uilocalnotification

对于有关推送/本地通知的某些问题,我找不到确切的答案。

  • 禁用推送通知是否还会禁用本地通知吗?
  • 我可以检测用户是否为我的应用程序禁用了推送通知吗?如果是这样,我该怎么做?编辑:正如我提交问题时,我发现:Determine on iPhone if user has enabled push notifications这是推荐的方法吗?

  • 谢谢!

    最佳答案

  • 禁用推送通知不会禁用本地通知,因为它们彼此独立。
  • 您可以通过这种方式进行检查,这确实可以工作。另一种选择是在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"];
    }
    
  • 关于iphone - 有关iOS上的本地通知和推送通知的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10789449/

    相关文章:

    ios - YTPlayer View在iPhone中无法正常工作

    iphone - 在 iphone 中选择应用内购买项目的困惑

    ios - 水平翻转视频如果这样则没有镜像效果

    ios - 如何设置uiimage的特定区域来处理触摸手势?

    swift - 如何保存/存储从 Parse 发送的推送通知并将其打印在任何 View Controller 上?

    iphone - 自定义分隔符图像在 UItableviewcell 中消失

    iphone - UIView 动画 block 不做任何更改

    ios - 为 AppStore 提交构建但仅在 TestFlight 上可见

    php - 通知声音和角标(Badge)不起作用

    ios - Entitlements.plist 与 Appname.Entitlements