How to handle push notifications if the application is already running?

You can implement application:didReceiveRemoteNotification: Here is a possible sample code: – (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { NSString *message = nil; id alert = [userInfo objectForKey:@”alert”]; if ([alert isKindOfClass:[NSString class]]) { message = alert; } else if ([alert isKindOfClass:[NSDictionary class]]) { message = [alert objectForKey:@”body”]; } if (alert) { UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@”Title” message:@”AThe … Read more

How to get back “Allow Push Notifications” dialog after it was dismissed once?

Here’s how Apple say you can do it: Resetting the Push Notifications Permissions Alert on iOS The first time a push-enabled app registers for push notifications, iOS asks the user if they wish to receive notifications for that app. Once the user has responded to this alert it is not presented again unless the device … Read more

Alternative to UserNotificationCenterDelegate’s willPresent when app is in background

For iOS 10 local notifications your out of luck. For iOS 10 remote notifications —regardless of user interaction you can receive callbacks using application(_:didReceiveRemoteNotification:fetchCompletionHandler:). (It’s kind of confusing that they deprecated most notification related methods but not this one) Callback for when app is in foreground and you’re about to show the notification: func userNotificationCenter(_ … Read more

application:didReceiveRemoteNotification:fetchCompletionHandler Not Called

application:didReceiveRemoteNotification:fetchCompletionHandler: gets called even if the app is suspended, not running at all, backgrounded, or active. Also worth noting that the method is iOS 7 only. Here is the apple documentation. HOWEVER if the app was forcibly closed (i.e. by killing with the app switcher), the app will not be launched. (see SO answer) EDIT: … Read more

PushSharp APNS production: The credentials supplied to the package were not recognized (development works fine though)

I figured out the problem. I revoked and regenerated the certificate again, and this time I only exported the private key (without the certificate). In Keychain access, I exported as .p12 and used the new file and it worked. For some reason, PushSharp wasn’t play well with .p12 when both certificate and private key are … Read more

didReceiveRemoteNotification: fetchCompletionHandler: open from icon vs push notification

Ok I figured it out. The method is actually called twice (once when it receives the push, and once when the user interacts with the icon or the notification). – (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { if(application.applicationState == UIApplicationStateInactive) { NSLog(@”Inactive”); //Show the view with the content of the push completionHandler(UIBackgroundFetchResultNewData); } else if … Read more