Receive push notifications in different states

I know that this topic has been discussed, but I see conflicting steps all the time, and I just lose more and more.

I just want to know what happens when my application is in the background and it receives a push notification.

I know that:

While in the foreground - application: didReceiveRemoteNotification: is called and there are no warnings, icons or sound.

not started yet - a warning signal, icon and / or sound are displayed and played, and if the user clicks the "View / Open" (Action) button of the notification, the application starts and the application is called: doneFinishLaunchingWithOptions: and the notification payload is transmitted if the user closes the notification and clicks the application icon, the same method is called, however, notification information is not transmitted.

in the background - Here I am confused. I need to know if there is work in the background or is paused, it matters in any case, which method is called, and if a warning, icon and / or sound is displayed / played.

Thanks.

+4
source share
1 answer

You can find this answer in How to respond to a push notification if the application is already running in the background is useful.

Basically, you can find out if your application was simply brought to the forefront or not in the application: didReceiveRemoteNotification: using this bit of code:

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { if ( application.applicationState == UIApplicationStateActive ) // app was already in the foreground else // app was just brought from background to foreground ... } 
+5
source

All Articles