Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Every Push Notification Banner is shown twice on iOS9 [duplicate]

Since a few hours we have a strange issue in our iOS app: every push notification received on the home screen of iOS will trigger/show the same notification banner twice with a 2 sec delay between them.

  • It only happens on devices with iOS 9.x. On iOS 8.x devices everything is still working as expected.
  • If I set a break point in -[AppDelegate application:didReceiveRemoteNotification:fetchCompletionHandler:] it is only called once for each push notification.

Also we did no change in the backend recently (at least a weak) and it also happens for client which are already released and we are 100% certain we did not see the issue before.

We did however change the capability in Xcode of the current development app and had to generate new provisioning profiles as the old ones where tagged as "Invalid".

So for us it looks like an issue on Apple sides. Any suggestions what more to try/check or what to do?

like image 600
SKerkewitz Avatar asked Dec 11 '15 11:12

SKerkewitz


People also ask

Why are my notifications doubling?

Android devices with 2 copies of the app installed on the device can also receive duplicate notifications. This could happen if you have a production and staging / dev app installed at the same time with different Android package names.

Why does Instagram have double notifications?

If you've added multiple Instagram accounts, you may get push notifications from any account that has them turned on. This depends on when you last logged in and the number of devices that are logged in to an account.

How do I fix Apple push notifications?

You can fix an iPhone that's not getting notifications by restarting it or making sure notifications are turned on. You should also make sure your iPhone is connected to the internet so apps can receive notifications. If all else fails, you should try resetting the iPhone — just make sure to back it up first.


2 Answers

It seems like I had exactly the same issue as this dude had: I called [registerUserNotificationSettings:] twice.

Be aware that it might not be as obvious as you think to see if you called the method once or twice:

I called it once on purpose in specific UIViewController. Unfortunately I also called it each time in didFinishLauchingWithOptions:. Don't let yourself be fooled because you see the dialog only once.

If you want to be sure add a logging output in -[AppDelegate application:didRegisterUserNotificationSettings:]. In my case the callback was called twice after I hit OK on the permission dialog.

Since I remove the misplace call in didFinishLauchingWithOptions: I did not see anymore double notifications.

like image 184
SKerkewitz Avatar answered Oct 30 '22 19:10

SKerkewitz


I submitted a bug report to Apple (Ticket# 23569779) and the issue appears to have been corrected in iOS 9.2.1 beta (Build: 13D11)

I was experiencing the same issue on iOS9.1 (Build: 13B143) and iOS9.2 (Build: 13c75) for both local and remote notifications across multiple apps.

The simplest way for me to recreate the issue is to schedule a local notification within my app delegate when the app is backgrounded.

- (void)applicationDidEnterBackground:(UIApplication *)application {

    UILocalNotification *notification = [[UILocalNotification alloc] init];

    notification.repeatInterval = NSDayCalendarUnit;
    [notification setAlertBody:@"My test."];
    [notification setFireDate:[NSDate dateWithTimeIntervalSinceNow:1]];
    [notification setTimeZone:[NSTimeZone defaultTimeZone]];
    [application setScheduledLocalNotifications:[NSArray arrayWithObject:notification]];
}

This will result in the notification banner appearing twice:

Duplicate banner images

like image 30
gatlinhebert Avatar answered Oct 30 '22 20:10

gatlinhebert