does my app display second time notification iOS 9

强颜欢笑 提交于 2019-12-01 03:54:09

问题


I am receiving the duplicate Notification. for both Remote notification and Local notifications.

I have used the following code

[application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil]];

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0){
    [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
    [[UIApplication sharedApplication] registerForRemoteNotifications];
}
else{
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
     (UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];
}

-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken{
NSString *strDevicetoken = [[NSString alloc]initWithFormat:@"%@",[[[deviceToken description] stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]] stringByReplacingOccurrencesOfString:@" " withString:@""]];
NSLog(@"devicetoken = %@",strDevicetoken);}

i am Receiving Duplicate push notifications all the time.


回答1:


I think this is a bug on iOS9 somewhere. I have noticed that a large percentage of my app send duplicate notifications. StackoverFlow's iOS app, Apple's, iTunes Connect app and a few others. Pretty sure its the same issue you're having. Maybe file a radar with Apple.




回答2:


I had a similar issue, and in my case problem was in calling method registerUserNotificationSettings: two times. Seems that calling this method more than 1 time leads to duplicate notifications on iOS 9.

So if you have the same situation, try these two steps:

  1. Remove all extra calls of registerUserNotificationSettings: in your code.
  2. Then Reinstall the app.

This should fix the issue.



来源:https://stackoverflow.com/questions/33889878/does-my-app-display-second-time-notification-ios-9

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!