Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I differentiate between push notifications received in app and touched from outside the app?

I have push notifications setup in my app. I have the method:

 - (void)application:(UIApplication *)application didReceiveRemoteNotification:     (NSDictionary *)userInfo
 {
      if()
      {
           //app is in foreground to get here
      }
      else if()
      {
           //app is in background and then the notification is clicked, to get here
      }
 }

I need to differentiate between touches of the notification outside the app, and simply receiving the notification in the app. Any help?

like image 560
SirRupertIII Avatar asked Jul 12 '13 09:07

SirRupertIII


People also ask

What is the difference between push notifications and in-app notifications?

While push notifications target users who aren't currently using the app to (hopefully) bring them back, in-app notifications reach a captive audience of users who are in your app and already engaged. Like push notifications, in-app notifications are, technically speaking, interruptions.

How do I know if push notifications are on?

Turn on notifications for Android devicesTap More on the bottom navigation bar and select Settings. Tap Turn on notifications. Tap Notifications. Tap Show notifications.

What's the difference between a push notification and a text message?

Push notification vs. text message — what's the difference? Text messages are electronic messages sent between phones while push notifications are brief alerts triggered by an application. Learn when to use each to maximize the reach of your message.


1 Answers

- (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
    ...
}
like image 131
Baby Groot Avatar answered Sep 20 '22 10:09

Baby Groot