本文介绍了接收重复推送通知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.
此答案中的更多详细信息:
More details in this answer:https://stackoverflow.com/a/35064911/4495995
这篇关于接收重复推送通知ios9的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!