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
Xcode 10, Command Codesign Failed with a Nonzero Exit Code
Error: Cuicatalog: Invalid Asset Name Supplied: (Null), or Invalid Scale Factor:2.000000
Storyboard Reference in Xcode, Where Should We Use It
How to Generate a Barcode from a String in Swift
How to Mimic Keyboard Animation on iOS 7 to Add "Done" Button to Numeric Keyboard
Avplayer Stops Playing and Doesn't Resume Again
Uirefreshcontrol on Uicollectionview Only Works If the Collection Fills the Height of the Container
iOS Uialertview Button to Go to Setting App
iOS 11 Safe Area Layout Guide Backwards Compatibility
How to Draw a Circle in iOS Swift
How to Detect That the App Is Running on a Jailbroken Device
iOS Nsattributedstring on Uibutton
Exc_Bad_Instruction (Code=Exc_I386_Invop, Subcode=0X0) on Dispatch_Semaphore_Dispose
Wrap Items in a Horizontal Uistackview on Multiple Lines
Bounding Box from Vndetectrectanglerequest Is Not Correct Size When Used as Child Vc
How to Handle Push Notifications If the Application Is Already Running