我有两台 iPad mini(ios8.3 和 ios9.1)和一台 iPad mini 2。
在 iPad mini 2 (ios.9.1) 上:运行良好。
在 iPad mini (ios.8.3) 上:有时不调用方法 didRegisterForRemoteNotificationsWithDeviceToken
在 iPad mini (ios.9.1) 上:有时不会调用 didRegisterForRemoteNotificationsWithDeviceToken 方法
我正在研究 XCode7.2、Objective-C
最佳答案
它是什么设备应该无关紧要。 您是否对 iOS8 和 9 使用了不同的调用?
您在应用程序的哪个位置进行注册调用?通常的过程是在应用程序启动时进行调用。
if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerUserNotificationSettings:)]) {
//iOS 9
UIUserNotificationSettings* notificationSettings = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound) categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:notificationSettings];
}
else
{
//iOS < 9
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound|UIRemoteNotificationTypeBadge)];
}
关于ios - 有时不调用 didRegisterForRemoteNotificationsWithDeviceToken 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33955980/