Snehal Patil
Snehal Patil

Reputation: 93

Determine if user did not clicked on the notification, when app is in the background

Is there any way to find out after notification is been sent, how many users clicked on the notification and how many people didnt click on the noficiation event (badge) when the app is in the background?

I am more interested to find out how many people didnt click, as people who clicked can be tracked as app will go in the foreground and request can be made vs if app is in the background, your http request may get lost.

Upvotes: 1

Views: 1134

Answers (2)

Nitin Alabur
Nitin Alabur

Reputation: 5812

update your app delegate code to the following code:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
        [super application:application didFinishLaunchingWithOptions:launchOptions];
        NSDictionary *remoteNotif = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];

        if(remoteNotif)
        {
            //launched from push notification
        }else{
            //Did not launch from push notification (tapped on app icon, or from multi tasking)
            //**Didn't click on notification**
        }
    }

and this:

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
    if([application applicationState] == UIApplicationStateActive) {
       // app was open, did not display the push alert/banner/badge
       // **Didn't click on notification**
    }else{
        //launched from push notification
    }
}

Its quite self explanatory. you can track when app was opened by tapping on a push notification and when it was opened without tapping on a notification.

Upvotes: 3

onnoweb
onnoweb

Reputation: 3038

I guess the closest you can come to know who didn't click your notification is by checking in your AppDelegate's didFinishLaunchWithOptions method that your app didn't get launched as a result of the user tapping a notification after you send out the notification. In other words, I think you answered your own question in your question.

Upvotes: 0

Related Questions