Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is app not getting registered for push notifications in iOS 8?

I upgarded my Xcode to Xcode 6.0.1, now remote notification registration is not happening for iOS 8 device. It is working fine for iOS 7 device.

I have added the code in app delegate as mentioned below:

    //-- Set Notification
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{
    UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIRemoteNotificationTypeBadge
     |UIRemoteNotificationTypeSound|UIRemoteNotificationTypeAlert) categories:nil];
    [[UIApplication sharedApplication] registerUserNotificationSettings:settings];

    NSLog(@"current notifications : %@", [[UIApplication sharedApplication] currentUserNotificationSettings]);
}
else
{
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
     (UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];
}

Even the current notification is present, and it is not nil.

And yet the below method is not called :

- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken

Screenshot below explains that I have enabled certain options in background mode:

enter image description here

And the notification is set in the device settings for my app.

like image 586
user1899840 Avatar asked Sep 26 '14 06:09

user1899840


People also ask

How do I enable push notifications on my iPhone 8?

Go to Settings and tap Notifications. Select an app under Notification Style. Under Alerts, choose the alert style that you want. If you turn on Allow Notifications, choose when you want the notifications delivered—immediately or in the scheduled notification summary.

Why push notification is not working for iOS?

Go to iOS' settings → "Your app name" → Notifications to ensure notifications are enabled for your app. You will need to restart your app after enabling push notifications. If you find a recent install with a push token in the debug tool, make sure your app is not opened in the foreground during your tests.

Why are my notifications not working on iPhone 8?

You can fix an iPhone that's not getting notifications by restarting it or making sure notifications are turned on. You should also make sure your iPhone is connected to the internet so apps can receive notifications. If all else fails, you should try resetting the iPhone — just make sure to back it up first.


1 Answers

You need to call

[[UIApplication sharedApplication] registerForRemoteNotifications];

in your iOS8 code path, after registering the user notification settings.

like image 166
Léo Natan Avatar answered Sep 17 '22 08:09

Léo Natan