Push Notification Integration
Visit Mobile Push channel configuration page for push notifications integration guidelines.
In order to send notifications to your mobile users using Growlytics platform, you will need to add FCM messaging listeners to your apps.

Step 1: Register FCM Messaging Service

Register an Growlytics' FCM messaging service in android manifest file as mentioned in example below. If you have already registered FCM messaging service, you can call Growlytics's updateFCMToken() and updateFCMToken() methods.
Growlytics FCM Service
If you have already implemented FCM Messaging Service
AndroidManifest.xml
1
// Skip adding this if you have already added in previous step
2
<service android:name="com.growlytics.android.sdk.FcmMessagingService">
3
<intent-filter>
4
<action android:name="com.google.firebase.MESSAGING_EVENT" />
5
</intent-filter>
6
</service>
Copied!
FcmMessagingService.java
1
@Override
2
public void onNewToken(String s) {
3
super.onNewToken(s);
4
5
// Call Growlytics's updateFCMToken() method
6
com.growlytics.android.sdk.FcmMessagingService.updateFCMToken(
7
token,
8
getApplicationContext()
9
);
10
11
}
12
13
@Override
14
public void onMessageReceived(RemoteMessage message) {
15
super.onMessageReceived(message);
16
17
// Call Growlytics's updateFCMToken() method
18
com.growlytics.android.sdk.FcmMessagingService.onMessageReceived(
19
message,
20
getApplicationContext()
21
);
22
23
}
Copied!

Step 2: Register Broadcast Receiver

In order to receive notifications in background, add a receiver as mentioned in example below. If you have already registered FCM messaging service, you can call Growlytics's onNotificationReceived()method.
Add Growlytics Broadcast Receiver
If you have already implemented Broadcast receiver
AndroidManifest.xml
1
<receiver
2
android:name="com.growlytics.android.sdk.GrwPushNotificationReceiver">
3
</receiver>
Copied!
PushNotificationReceiver.java
1
public class GrwPushNotificationReceiver extends BroadcastReceiver {
2
3
@Override
4
public void onReceive(Context context, Intent intent) {
5
6
// Call Growlytics's updateFCMToken() method
7
com.growlytics.android.sdk.GrwPushNotificationReceiver.onReceive(
8
context,
9
intent
10
);
11
}
12
13
}
Copied!

Step 3: Configure FCM credentials

Visit Mobile Push channel configuration page for configuring FCM credentials.

Additional Notes

Structure of the payload with a Growlytics FCM push notification.
Key
Data Type
Description
glytcs_pnf
boolean
If this field is present, means notification is received from Growlytics.
glytcs_id
string
Notification tracking id used by Growlytics.
glytcs_img
string
Url of an notification Image. If given, this URL will be used to show large image in notification.
glytcs_tl
string
Notification title, must be present or app name will be used as title.
glytcs_msg
string
Notification body, must be present, if not provided, notification will not be shown.
glytcs_chnl
String
Notification channel id, must be present and channel must be created by app, if given channel not registered, notification will not be rendered.
glytcs_dl
string
If present, this is a deep link that must be followed at the time of notification open.
glytcs_sbt
string
Notification sub-title, will be displayed next to app name in notification.
glytcs_clr
string
Color for small icon in notification. It Must be in hex or else color will be ignored.
glytcs_pr
string
Priority for push notification [Low, High, Max]
glytcs_dnr
boolean
If present, notification will not be shown, it will be ignore