MoEngage Docs

Push Notification

Configuring your MoEngage Account

Copy the Sever Key from the GCM/FCM console and add it to the MoEngage Dashboard(Not sure where to find the Server Key refer to Getting FCM/GCM Server Key ). To upload it, go to this link and add the Server Key(named as GCM key) and package name.
Please make sure you add the keys both in Test and Live environment.

Adding meta for push notification

Along with the App Id and the notification small icon large icon and sender id(only if using GCM library) to the builder.

MoEngage moEngage =
        new MoEngage.Builder(this, "XXXXXXXXXX")

Notification Small Icon Guidelines

Notification small icon should be flat, pictured face on, and must be white on a transparent background. Refer to the developer docs for more details.

Push Token Registration by MoEngage

Please skip this section if your application is handling push token registration.

Push token registration is a very vital part of push notification, without push token one cannot send out push notifications. The MoEngage SDK registers for push token by default.

Callback for Push Token

MoEngage SDK provides a callback to get the push token whenever MoEngage SDK is registering for Push Token. Implement the below interface in your Application class.

   * Interface definition for a callback which is invoked whenever a push token  is generated.
  public interface OnTokenReceivedListener {
     * Called whenever push token is generated.
     * @param token Push token.
    void onTokenReceived(String token);

Register your listener using the below API



We highly recommend you to use MoEngage's Push registration. Push registration fails many times and due to network/server issues, MoEngage SDK has fallback mechanisms to retry and minimize this failure.

Push Token Registration by your application.

Please skip this section if you are letting MoEngage SDK handle push token registration.

If your application wants to register for push token and pass the token to MoEngage SDK,
the application should pass the token to MoEngage SDK from the Registration Service used for getting the push token.

PushManager.getInstance().refreshToken(getApplicationContext(), token);

This should be called as soon as the application registers for push token.

Along with passing the push token to the SDK make sure you opt out of push token registration in the MoEngage initialising builder.

MoEngage moEngage = new MoEngage.Builder(this, "XXXXXXXXXX")

Please make sure token is passed to MoEngage SDK on Application update. It is very important when migrating to MoEngage.

What's Next

Based on whether you are using GCM/FCM move to library specific configuration.

Configuring GCM
Configuring FCM

Push Notification

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.