How to find out if a user has allowed push notifications

I saw this question , but did not understand if there is a clear answer.

I can tell if the user clicked "not allow" when starting the SECOND application by setting the flag:

BOOL didRequest = [[NSUserDefaults standardUserDefaults] boolForKey:@"DidRequestPushNotifications"];
    UIRemoteNotificationType types =    [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
    if (types == UIRemoteNotificationTypeNone && didRequest)
    {
        [self showAlertToUserToEnableRemoteNotificationsOnDeviceInSettings];
    }
    [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"DidRequestPushNotifications"];
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];

But for the first launch of the application, both delegation methods for success and failure are not called, which means that there is no way to find out for sure.

Any work around?

+1
source share
1 answer

, , , , - , NSUserDefaults.

, nil .

0

All Articles