Push Notifications Android


A guide for integrating Kochava Push Notification support with the Kochava Android SDK. Before proceeding you should complete the following:

  1. Integrate the Kochava Android SDK.
  2. Integrate Firebase Cloud Messaging.
  3. Add your FCM/GCM Server Key to your app on the Kochava Dashboard.

 

NOTE: To track uninstalls you will need to go through the integration process for Push Notifications.

 

Integration

To fully integrate push notifications with Kochava you must add code in three places. The code provided below is an example integration. It is expected that your implementation will have some variation.

 

FirebaseInstanceIdService:

Your implementation of this class is added when you integrate Firebase Cloud Messaging. You will pass the Firebase InstanceId Token from here to Kochava when it is first created and every time it is refreshed. Note: if you are upgrading an app that already has push enabled you need to pass it to Kochava directly after the Kochava Tracker configuration in addition to here to ensure that any tokens that existed prior to the Kochava integration are included.

 

 

FirebaseMessagingService:

Your implementation of this class is added when you integrate Firebase Cloud Messaging. Kochava Push uses the FCM Data Message format. This format ensures all push messages are received by the “onMessageReceived” method no matter if the app is in the foreground or background. The fields included in the RemoteMessage data are as follows.

  1. kochava – Campaign tracking information to be added to the notification bundle and sent with the Push Open event.
  2. title – Notification title.
  3. message – Notification message body.
  4. icon_resource_id – Mapping string to an app internal drawable resource.
  5. link – Launch deeplink Uri.

 

Silent Push –

In order to track app uninstalls Kochava will send a “silent” push that contains the an empty message string. You should check “message” and if it is both present and an empty string consider the push to be silent and do not show the notification.

 

 

Main/Launcher Activity:

This class is your push entry point. While this can be the same as your launcher entry point it is suggested to use an Activity dedicated to push launches.

 


Disabling Push

The SDK provides a mechanism for disabling push to a specific install by sending a push token with a remove command. This would typically be used if you provide a way in app for the user to disable push messages. If you support disabling push you need to ensure you check the enable state in your FirebaseInstanceIdService before sending refreshed tokens. You also need to ensure that when enabled you send the current token right away.

 

 
 

Last Modified: Jun 14, 2018 at 11:00 am