First of all, I am on iPhone 6 Plus/iOS 8.1 and I've tried everything here: why didRegisterForRemoteNotificationsWithDeviceToken is not called
Still no avail. To summarize:
In application:didFinishLaunchingWithOptions:
I call:
if([application respondsToSelector:@selector(registerUserNotificationSettings:)]){
//iOS 8+
[application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
}else{
//pre-iOS 8
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
}
In application:didRegisterUserNotificationSettings:
I call:
[application registerForRemoteNotifications];
I've checked it with a breakpoint, it DOES get called. I've also implemented two methods:
application:didRegisterForRemoteNotificationsWithDeviceToken:
and
application:didFailToRegisterForRemoteNotificationsWithError:
However, neither of them is called. Not an error, nothing. No error at the console either. (I've had an issue about entitlements earlier today, but creating new certificate/provisioning profile solved that)
What could be the issue?
UPDATE: Here is something. In application:didRegisterUserNotificationSettings:
I've checked the notification settings and here is what I've got:
(lldb) po notificationSettings
<UIUserNotificationSettings: 0x170031cc0; types: (none);>
UPDATE 2: I've checked notifications again, and found out that now my app is added to the notifications in Settings, it's enabled, given permissions. But still, the handler is not called. Types are none. I'm 99% sure it's related to the problem.
UPDATE 3: I've tested on another device (iPod touch, iOS 8.1), and I've got no problems there. It immediately called the application:didRegisterForRemoteNotificationsWithDeviceToken:
method with its token. The problem is specific to my iPhone.
I got a similar problem, the code was already implemented and working fine. Suddenly, after some adjustments, it just don't work it anymore.
The scenario running on device was:
I tried everything, almost reset all push configurations and certificates and provisioning profiles, etc.. All devices with the last version was working, but when I install the new version, just don't work anymore.
To solve this, I just did this:
After 6h fighting with Xcode, that was my solution, without any explanation.
I hope this help someone.