How to detect if user tap on "Don't Allow" on Apple's push notification confirmation alert

apple-push-notifications, ios, ipad

Solution

I'm sure someone will need a solid and simple answer to this (like I once did) -- so here you go. Directly after calling `[[UIApplication sharedApplication] registerForRemoteNotifications];` you can use `NSNotificationCenter` beautifully like so:

[[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"
                                                  }
                                              }];

NOTE: My device is currently running iOS 9.2, my Xcode is version 7.2, and my Deployment Target is 8.0.

Problem

I want to fire some event if user taps on "Don't Allow" button on the apple's push notification alert message. Is there any notification getting fired or any other way to detect this action from the user?

Original source