What is the callback method if you click "Do Not Allow" in the Push Notification pop-up message?

A push notification pop-up window will appear, which appears when you reinstall the application. There are two options: OK and Do not allow (if I remember it correctly).

I want to know what the callback method is if I click "Do not allow". The fact is that I implemented didFailToRegisterForRemoteNotifications because I thought that if I click "Do not allow", it will be directly to this method in AppDelegate. However, this method has not been called.

My problem: I need to know the event when the user clicks the "Do not allow" button. Is there any way to do this? I would appreciate any help. Thanks.

+4
source share
2 answers

However, there is no delegate callback from here: Callback method if the user rejects the release notification hint?

You can have a BOOL variable to test it in AppDelegate,

AppDelegate.m

// declare a BOOL 
BOOL allow = NO;

- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
{
  allow = YES;
  [self doWhatever];
}

- (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error
{
  allow = YES;
  [self doWhatever];
}
-3
source
didFailToRegisterForRemoteNotifications 

when the connection with the Apple registration service fails, there is no way to find out that the user that just clicked does not allow, but you can check the UIApplication, there is a way to find out the registration status of PushNotification

NSUInteger rntypes = [[UIApplication sharedApplication] enabledRemoteNotificationTypes]; 
if (rntypes == UIRemoteNotificationTypeNote) {
    // application is not registered for any type of push notification
}
-3
source

All Articles