Support Home > SDK Integration > Cordova – SDK Integration > Cordova – Push Notification

Cordova – Push Notification

Estimated Time to Complete
15 Minute

Kochava Push Engagement provides the ability to target desired user segments in order to send meaningfully designed messages. See the Engagement Overview documentation for more information.

In order to integrate with Kochava Push you must, at a minimum, enable push notifications by passing the user’s push registration token to the Kochava SDK and handle app launches from a Kochava push notification by sending a Push Opened event containing engagement campaign information. This document assumes you have already integrated your platform’s push notification support and enabled Push on the Kochava Dashboard.


Enabling Push Notifications

In order to enable Kochava push notifications you must pass the push registration token to the Kochava SDK. This will occur the first time the token is created and any time it is updated. If you support opt in or out then this should only occur when the user is currently opted in and during the moment they opt in.

 

Example (Retrieving the Push Registration Token):

 

Developer API Reference:

KochavaTracker.addPushToken(String)


Handling App Launches

When the app launches you must detect if it was caused by the user clicking on a Kochava push notification and if so send a Push Opened event containing the Kochava engagement campaign information to track the launch.

 

Example (Send Push Opened Event):

 

Developer API Reference:

KochavaTracker.sendEventMapObject(String, MapObject)
Standard Event Types


Building the Notification

Android Only:

On Android, Kochava Push uses the FCM Data Message format. This format ensures consistent behavior regardless of if the app is in the foreground or the background. However it requires that the app is responsible for building and displaying the notification when it is received. The app must also determine if it should show the notification based on being in the foreground or background. The “kochava” key contains the engagement campaign information and is always included. Other fields are optional and may vary.

  1. kochava — Campaign tracking information to be added to the notification bundle and sent with the Push Opened event.
  2. silent — If this key is present the push was used for tracking uninstalls and should be ignored.
  3. title — Notification title.
  4. message — Notification message body.
  5. icon_resource_id — Mapping string to an app internal drawable resource.
  6. link — Launch deeplink Uri.

 

Example (Building the Notification):


Other Functionality

Disabling Push Notifications:

If you provide the ability for users to opt in or out of Kochava Push Notifications you can remove an existing push token which will disable usage of that token by Kochava. If disabled ensure that you do not pass any updated tokens to Kochava until the feature has been enabled again and if enabled immediately add the current token to the Kochava SDK.

 

Example (Removing a Push Registration Token)

 

Uninstall Tracking:

In order to track uninstalls Kochava sends a “silent push” to all push registration tokens periodically. When the token becomes invalid it can be determined that the user uninstalled the app. On iOS these automatically resolve in the background and no action is required. However on Android these show up in the app and must be specifically ignored. A silent push can be identified and ignored by checking that both the keys “kochava” and “silent” are present within the notification extras map.

 

Application Icon Badge Number:

iOS Only —

On your Kochava dashboard you may indicate that you want the application icon badge number set when push notifications are sent. If you enable this option you should be prepared to clear your badge number when your application becomes active, or at some other appropriate time. For more information see instance property applicationIconBadgeNumber.

 

Developer API Reference:

KochavaTracker.removePushToken(String)

 
 

Last Modified: Feb 26, 2019 at 10:22 am