How to get Push Notifications when app is opened. Get Push Notifications only when app is close or in background.
-
in ios 0 thisfeature is available if you want to another ios version than you have create own notificationview check this http://stackoverflow.com/questions/14872088/get-push-notification-while-app-in-foreground-ios – Jigar Feb 09 '17 at 10:34
3 Answers
When the app is background or foreground
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler
will be invoked when app is not in memory ,user interaction is needed on the push notification which opens the app and need to handle it on
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

- 572
- 7
- 18
Your question is not very clear but if you want to show notifications in notification window even when your app is active then you need to handle the same in
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)pushMessage
and post a new local notification with the same payload. which you can then handle in
- (void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNotification *)notif

- 39
- 7
Generally If the application is running in the foreground, iOS won't show a notification banner/alert.That's by design.When app is in forground if you want to show push notification you can use UserNotification Framework for iOS 10 and it shows or displaysnotification as banner.Also you can use UILocalNotification to achieve this.Mainly we use didReceiveRemoteNotification method for achieving this.Now we have UIUserNotification methods from iOS 10.
When application is foreground and background state getting push notification

- 1
- 1

- 9,459
- 3
- 32
- 39
-
Instead of linking to other posts on Stack Overflow in an answer, vote to close this question as a duplicate. – JAL Feb 10 '17 at 02:14