我需要设备令牌在我的应用中实现推送通知,因为我从didRegisterForRemoteNotificationsWithDeviceToken方法获取设备令牌,但最近它不起作用。
有关详细信息,请在didFinishLaunchingWithOptions方法中找到以下代码。
if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) {
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIRemoteNotificationTypeBadge
|UIRemoteNotificationTypeSound
|UIRemoteNotificationTypeAlert) categories:nil];
[application registerUserNotificationSettings:settings];
} else {
UIRemoteNotificationType myTypes = UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound;
[application registerForRemoteNotificationTypes:myTypes];
}
我还添加了委托didRegisterUserNotificationSettings。
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings {
if (notificationSettings.types != UIUserNotificationTypeNone) {
NSLog(@"didRegisterUser");
[application registerForRemoteNotifications];
}
}
感谢您提前做出如此迅速的回复,我希望我能更清楚地解决我的问题。
非常感谢任何帮助。
答案 0 :(得分:4)
我面临同样的问题。我在搜索期间找到了一些解决方案,因为WWDR中间证书刚刚过期(2016年2月14日)。这可能会导致问题。
您可以尝试以下步骤:
此外,Apple还列出了几个已知问题。请参阅以下链接:https://developer.apple.com/support/certificates/expiration/