Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Receiving duplicate push notification ios9

Tags:

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 
like image 651
iPhone Avatar asked Sep 29 '15 09:09

iPhone


People also ask

Why am I getting the same notifications twice?

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 do I get two notifications from Instagram?

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.

Why do I keep getting two notifications on my iPhone?

As such, just a few minutes later, your device lights up, vibrates, or rings again to remind you of the same message notification a second time. The reason for this is that Apple sets notifications and alerts to repeat once by default on iOS devices.

Are push notifications spam?

Firstly, push notifications used to look like a spam email but get developed into personalised, interactive notifications that provide information and value with the shortest wording possible. They can be triggered based on a user's request or the action performed by a user.


1 Answers

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

like image 162
Vladimir K Avatar answered Oct 01 '22 17:10

Vladimir K