Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

does my app display second time notification iOS 9

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.

like image 489
Vvk Avatar asked Nov 24 '15 09:11

Vvk


2 Answers

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.

like image 55
Vladimir K Avatar answered Nov 15 '22 04:11

Vladimir K


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.

like image 32
Robert J. Clegg Avatar answered Nov 15 '22 03:11

Robert J. Clegg