registerUserNotificationSettings not showing prompt iOS 8

I can’t seem to get a prompt to show for registerUserNotificationSettings in iOS 8.1 or 8.2.

Here is what I’m doing in didFinishLaunchingWithOptions:

  • UINavigationBar custom back button without title
  • iOS app compatibility issue
  • AFNetworking 2.0 Get JSON from code 400 in failure block
  • Invalid Binary File after uploading on ITunesConnect
  • iOS: playing a frame-by-frame greyscale animation in a custom colour
  • How to programmatically add a UITabBarController & UINavigationController in AppDelegate?
  •   if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) {
           #ifdef __IPHONE_8_0
            UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeAlert
                                                                                                 |UIUserNotificationTypeSound | UIUserNotificationTypeBadge) categories:nil];
            NSLog(@"Reg settings %@", settings);
            [application registerUserNotificationSettings:settings];
        #endif
        }
    

    Also getting the correct call back here:

    - (void)application:(UIApplication *)application
    didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings{
        NSLog(@"Did register - %@", notificationSettings);
    }
    

    Yet no prompt is ever displayed. What’s even more annoying is that an alert will display when the device is locked, but won’t give the notification alert sound. Any ideas on a work around?

    2 Solutions Collect From Internet About “registerUserNotificationSettings not showing prompt iOS 8”

    Using your code, I get the prompt on the first app launch, and only on the first launch. But afaik, that’s the expected behavior in iOS.
    At least it’s the same for photo library, microphone access etc:

    Permissions Prompt Behavior

    1. Popup on first usage (or at least the request to use it)
    2. Apple adds an entry in settings (e.g. Privacy, or just under Settings for notifications)

    First usage

    Permissions promt

    In the Settings App you can configure Notifications for each app

    1. Scroll down, select your app
    2. Select Notifications
    3. Enable/Disable them, or adjust their behavior

    Resetting the Push Notifications Permissions Alert on iOS

    The first time a push-enabled app registers for push notifications,
    iOS asks the user if they wish to receive notifications for that app.
    Once the user has responded to this alert it is not presented again
    unless the device is restored or the app has been uninstalled for at
    least a day.

    If you want to simulate a first-time run of your app, you can leave
    the app uninstalled for a day. You can achieve the latter without
    actually waiting a day by following these steps:

    1. Delete your app from the device.
    2. Turn the device off completely and turn it back on.
    3. Go to Settings > General > Date & Time and set the date ahead a day
      or more.
    4. Turn the device off completely again and turn it back on.

    Source: https://developer.apple.com/library/ios/technotes/tn2265/_index.html

    Change build target latest version you will see the popup message.
    Same issue with me in iOS 8 its not showing, but in iOS 10 its showing the alert pop message, This alert message will be displayed only once for the application cycle. Unless you delete and reinstall new one.

    - (void)registerLocalNotification{
    
        UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes: UIUserNotificationTypeAlert | UIUserNotificationTypeSound categories:nil];
        [[UIApplication sharedApplication] registerUserNotificationSettings:settings];
        [[UIApplication sharedApplication] registerForRemoteNotifications];
    }