我在 iOS9 中两次收到相同的推送通知,尽管它在 iOS8 中工作正常。
我已使用以下代码注册推送通知:
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000
if ([application respondsToSelector:@selector(registerUserNotificationSettings:)])
{
// use registerUserNotificationSettings
UIUserNotificationSettings *setting = [UIUserNotificationSettings settingsForTypes:( UIUserNotificationTypeSound | UIUserNotificationTypeAlert|UIUserNotificationTypeBadge) categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:setting];
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
else
{
// use registerForRemoteNotifications
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert |UIRemoteNotificationTypeBadge)];
}
#else
// use registerForRemoteNotifications
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
#endif
最佳答案
我在几个应用程序中遇到过这个问题,如果您调用 registerUserNotificationSettings:
超过 1 次,看起来会出现重复项。
此答案中的更多详细信息: https://stackoverflow.com/a/35064911/4495995
关于ios - 接收重复的推送通知 ios9,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32840916/