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
:
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?
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.
Update for iOS 11+:
Since iOS 11
Resetting the Push Notifications Permissions Alert on iOS
procedure seems not to be necessary anymore. Just un-/reinstall the app.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
First usage
In the
Settings
App you can configureNotifications
for each appNotifications
Resetting the Push Notifications Permissions Alert on iOS
Source: https://developer.apple.com/library/ios/technotes/tn2265/_index.html