本文介绍了ios9 接收重复推送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 iOS9 中两次收到相同的推送通知,尽管它在 iOS8 中运行良好.
I am receiving the same push notification twice in iOS9, although it is working fine in iOS8.
我使用以下代码注册推送通知:
I have used the following code to register with push notifications:
#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 次,看起来会出现重复.
I had this problem in several apps, and looks like duplicates appear if you call registerUserNotificationSettings:
more than 1 time.
此答案中的更多详细信息:https://stackoverflow.com/a/35064911/4495995
More details in this answer:https://stackoverflow.com/a/35064911/4495995
这篇关于ios9 接收重复推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!