iOS Push Notification Banner Shown Twice for a Single Push

iOS Push Notification Banner shown twice for a single Push

According to this answer on a similar question, this issue was reported as rdar://23569779 and should be fixed in the iOS 9.3 public release.

Please leave a comment if you reproduce this issue in iOS 9.3+

Supposedly fixed in:

iOS 9.2.1 beta (Build: 13D11)

Every Push Notification Banner is shown twice on iOS9

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.

IOS notification showing twice with default and my notification alert

 First uninstall the app and try it. It will work fine same problem i am facing.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

[Parse initializeWithConfiguration:[ParseClientConfiguration configurationWithBlock:^(id<ParseMutableClientConfiguration> configuration) {
configuration.applicationId = APPLICATION_ID;
configuration.clientKey = CLIENT_KEY;
configuration.server = AMAZON_SERVER;
}]];

[PFAnalytics trackAppOpenedWithLaunchOptions:launchOptions];

[Fabric with:@[[Digits class]]];

if([[NSUserDefaults standardUserDefaults] boolForKey:@"FirstLaunch"]!=TRUE)
{
[[NSUserDefaults standardUserDefaults] setBool:FALSE forKey:@"FirstLaunch"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
//storedevice Type in standardUserDefaults
[self setDeviceType];
#here i am edited

if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerUserNotificationSettings:)])
{

UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound) categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
[[UIApplication sharedApplication] registerForRemoteNotifications];

}
else
{

[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];

}

return YES;
}
// remove the below methods

- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings {
[application registerForRemoteNotifications];
}

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
// Store the deviceToken in the current installation and save it to Parse.
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
[currentInstallation setDeviceTokenFromData:deviceToken];
[currentInstallation saveInBackground];
}

- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err {
NSLog(@"Error in registration. Error: %@", err);
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
//[PFPush handlePush:userInfo];
if ([userInfo objectForKey:@"aps"]) {
NSMutableDictionary * apsData = [userInfo objectForKey:@"aps"];
NSString* alert = [apsData objectForKey:@"alert"];
...
...

UIAlertView* alertWindow = [[UIAlertView alloc] initWithTitle: alertHeader
message: message
delegate: self
cancelButtonTitle: @"OK"
otherButtonTitles: nil];

[alertWindow show];
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
} else {
[PFPush handlePush:userInfo];
}
}

UILocalNotification animates twice

I had the same exact problem a while ago and it was caused by multiple calls to registerUserNotificationSettings when initialising the notifications (in this case, in didFinishLaunchingWithOptions).

This post helped.

Send push Notification to Multiple Apps

Each app has its own deviceToken on that device. To send pushes to both apps you would need to send the push to both device tokens. The device will display both notifications.



Related Topics



Leave a reply



Submit