如何检测用户是否在Apple的推送通知确认提醒中点击"不允许"

san*_*ana 3 apple-push-notifications ipad ios

如果用户点击苹果推送通知提醒消息上的"不允许"按钮,我想发出一些事件.是否有任何通知被触发或以其他方式检测用户的此操作?

Lar*_*ses 14

我相信有人会需要一个坚实而简单的答案(就像我曾经做过的那样) - 所以你走了.在打电话后[[UIApplication sharedApplication] registerForRemoteNotifications];你可以直接使用NSNotificationCenter:

[[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification
                                                  object:nil
                                                   queue:[NSOperationQueue mainQueue]
                                              usingBlock:^(NSNotification * _Nonnull note) {
                                                  if ([[UIApplication sharedApplication] isRegisteredForRemoteNotifications]) {
                                                      //user tapped "Allow"
                                                  }
                                                  else{
                                                      //user tapped "Don't Allow"
                                                  }
                                              }];
Run Code Online (Sandbox Code Playgroud)

注意:我的设备当前正在运行iOS 9.2,我的Xcode是版本7.2,而我的部署目标是8.0.