CleverTap/clevertap-react-native

[iOS] Push Impression Integration Documentation Improvements?

Closed this issue · 1 comments

This is more of a multiple high-level feedback for push impressions integration in ios.

A. I was searching why impressions are not being triggered in the campaign stats on development mode. and I found this reply in on of the issues:

For test push notifications we do not raise the Push Impression event.

This is a bit harder to find.

B. I am using an ios physical device when integrating. I was able to trigger the push notifications after following the Notification Service Extension. But I have some observations:

  1. Notification Clicked is triggered even if when the notification shows up, I just wait for it to disappear in foreground while i run the app. (I was triggering the push notification using a custom event that is triggered by a button inside my app.) So is this intended? Or is there some issue on the way i integrated it?
  2. I'm trying to add NSLogs in every function indicated in the docs, and only willPresentNotification is triggered. As for didReceiveNotificationRequest inside NotificationService.m, it is also not triggered but i guess I want to confirm if this is because push impressions are not triggered on development mode?

If that's the case, how should users develop and test the push impressions feature?

I apologize if these are a bit convoluted but I am willing to coordinate with the maintainer to separate these issues, but for now, I wanted to phrase this in one issue as a feedback for the over-all docs.

Thank you!

Coordinating with the clevertap support, some final observations as i close this issue:

  1. "Please be informed that for preview and test we don't raise push imprerssions , however when you create a test campaign, targeting few of the test users it works perfectly."
  2. recordNotificationViewedEvent is what populates impressions on campaign stat page
  3. It's possible that handleNotificationWithData on willPresentNotification triggers Notification Clicked even if one does not click the notification on device. (Possible bug but this is my current findings, because i commented the line and it does not trigger incorrectly.)
/** For iOS 10 and above - Foreground, NOTE: Also works for iOS 8 **/
- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler{    
    /**
      Use this method to perform the tasks associated with your app's custom actions. When the user responds to a notification, the system calls this method with the results. You use this method to perform the task associated with that action, if at all. At the end of your implementation, you must call the completionHandler block to let the system know that you are done processing the notification.
      
      You specify your app's notification types and custom actions using UNNotificationCategory and UNNotificationAction objects.
      You create these objects at initialization time and register them with the user notification center. Even if you register custom actions, the action in the response parameter might indicate that the user dismissed the notification without performing any of your actions.
      
      If you do not implement this method, your app never responds to custom actions.
      
      see https://developer.apple.com/reference/usernotifications/unusernotificationcenterdelegate/1649501-usernotificationcenter?language=objc
      **/

    NSLog(@"%@: will present notification: %@", self.description, notification.request.content.userInfo);

    /** NOTE: As of CT SDK Version 5.2.1, this triggers Push Impressions / Impressions on Campaign Stat page, not Notification Viewed as indicated by name! **/
    [[CleverTap sharedInstance] recordNotificationViewedEventWithData:notification.request.content.userInfo];

    // if you wish CleverTap to record the notification open and fire any deep links contained in the payload, NOTE: This triggers Notification Clicked automatically
    // [[CleverTap sharedInstance]handleNotificationWithData:notification.request.content.userInfo openDeepLinksInForeground: NO];
    completionHandler(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge);
}