I have already
- (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
...
}
Now is that possible that I perform some some set of action when notification arrive, keeping the application in background; I don’t want to bring my app at foreground when notification is received; What I want is when notifications arrive, I just set some flags and (app is still in background) and when user open the app himself, he/she can view the message in some graceful way;
Summary: I don’t want to bring the application in foreground when notifications arrives, but want to perform some actions in my code keeping the app in background;
Thanks;
You will want to use
Since your app is in the background it won’t know anything about the incoming notifications. The notification is taken care of by iOS.
However, when your app opens due to a user swiping/tapping the notifications your app will get the launchOptions passed in the above method. If the user opens the app directly (tapping the app icon) the launchOptions will be empty. See the UIApplicationDelegate Protocol Reference for more details.
To retrieve remote notification payload you can do:
for the local notification payload you can do: