Introduction

Since Herow SDK 5.0, we support Push notification technology (in addition of local notification for geofence) and we can now create mobile engagement campaign on Herow platform to push the right message to the right user thanks to the power of location data & intelligence.

When you launch a push campaign it creates a remote notification sent by our server (Herow Platform) to Android devices using Firebase Cloud Messaging (FCM) . To ensure a good SDK integration and a smooth development experience, there are a few important steps that you need to read.

Registering for Push

Use Firebase Cloud Messaging (FCM) to register for push.

Step 1: Enable Firebase

To get started, follow the instructions at Add Firebase to Your Android Project .

Step 2: Herow Platform configuration

First you have get your FCM key on Firebase platform: Enable Platform KEY

To configure push notifications on your Herow platform, connect to my.herow.io with your login/password, go in your app environnement, then open settings and click on "push credentials". As you can see below, to enable push notification service on Android, you have to upload your google credentials json file and save it.

Enable Platform KEY

Enable Platform KEY

Step 3: Configure Token Registration

Herow SDK push notifications won’t work until a Firebase Cloud Messaging token is registered.

We recommended you to call the registerForPush method in the HerowInitializer class.

Note: We strongly recommend you to register automatically, if you are not using other push SDK inside your app. If your app uses several SDK push solution, see below section named "MULTI SDK : USING YOUR OWN FIREBASE MESSAGING SERVICE"

See the snippet below for an example:

public void onCreate() {
    [...]
         HerowInitializer.getInstance().registerForPush(true);
}

Note: While we strongly recommend you register your Firebase token in your application "onCreate()" function, the push token can be registered anywhere in your code.

Step 4: Displaying Push

Herow SDK notification code also uses HerowFireBaseMessagingService to handle open and click action tracking. This service is registered in the merged AndroidManifest.xml. Also, keep in mind that Herow SDK prefixes notifications from our system with a unique key to ensure we only render notifications sent from Herow SDK systems. You may register additional services separately in order to render notifications sent from other FCM services.

MULTI SDK : USING YOUR OWN FIREBASE MESSAGING SERVICE

If you already have a Firebase Messaging Service, then you will have to make the registration manually See the following snippet:

public void onCreate() {
    [...]
         HerowInitializer.getInstance().registerForPush(false);
}

You have to pass remoteMessage objects to Herow SDK. The system will only display a notification if the remoteMessage object originated from Herow SDK and will safely ignore if not.

public class MyFirebaseMessagingService extends FirebaseMessagingService {
  @Override
  public void onMessageReceived(RemoteMessage remoteMessage) {
    super.onMessageReceived(remoteMessage);
    if (HerowInitializer.getInstance().pushCenter().onMessageReceived(remoteMessage)) {
      // This Remote Message originated from Herow SDK and a push notification was displayed.
      // No further action is needed.
    } else {
      // This Remote Message did not originate from Herow SDK .
      // No action was taken and you can safely pass this Remote Message to other handlers.
    }
  }
}