Detect if the app was launched/opened from a push notification

See This code : – (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { if ( application.applicationState == UIApplicationStateInactive || application.applicationState == UIApplicationStateBackground ) { //opened from a push notification when the app was on background } } same as -(void)application:(UIApplication *)application didReceiveLocalNotification (UILocalNotification *)notification

Push notification issue with iOS 10

For iOS 10 using xCode 8 GM. I have resolved my issue with following steps using xCode 8 GM for iOS 10: 1) In the targets, under Capabilities enable Push Notifications to add Push Notifications Entitlements. 2) Implement UserNotifications.framework into your app. Import UserNotifications.framework in your AppDelegate. #import <UserNotifications/UserNotifications.h> @interface AppDelegate : UIResponder <UIApplicationDelegate,UNUserNotificationCenterDelegate> @end … Read more

Registering for Push Notifications in Xcode 8/Swift 3.0?

Import the UserNotifications framework and add the UNUserNotificationCenterDelegate in AppDelegate.swift Request user permission func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { let center = UNUserNotificationCenter.current() center.requestAuthorization(options:[.badge, .alert, .sound]) { (granted, error) in // Enable or disable features based on authorization. } application.registerForRemoteNotifications() return true } Getting device token func application(_ application: UIApplication, … Read more

Get push notification while App in foreground iOS

For displaying banner message while app is in foreground, use the following method. iOS 10, Swift 3/4 : // This method will be called when app received push notifications in foreground func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) { completionHandler([.alert, .badge, .sound]) } iOS 10, Swift 2.3 : @available(iOS … Read more