Push Configuration

Configuring your MoEngage Account

  • Ensure you have configured the Firebase application.
  • Ensure you have the FCM server key.
  • Ensure you add the FCM Server Key in the Dashboard --> Settings --> Channel --> Push --> Mobile Push --> Android.
    Ensure you add the keys in both the Test and Live environments.

Adding metadata for push notification

Metadata regarding the notification is required to show push notifications where the small icon and large icon drawable are mandatory.

For more information about API reference for all the possible options, refer to NotificationConfig.

Use the configureNotificationMetaData() to transfer the configuration to the SDK.

Kotlin Java

    val moEngage = MoEngage.Builder(this, "XXXXXXXX")
     .configureNotificationMetaData(NotificationConfig(R.drawable.small_icon, R.drawable.large_icon))     
     .build()
   MoEngage.initialiseDefaultInstance(moEngage)

Ensure that the SDK is initialized with the metadata in the onCreate() of the Application class for push notifications to work.

 

Notification Small Icon Guidelines

Notification small icon should be flat, pictured face on, and must be white on a transparent background.

 

Notification Runtime Permission

Android 13 (API level 33) and higher supports runtime permission for sending non-exempt(including Foreground Services (FGS)) notifications from an app POST_NOTIFICATIONS. This change helps users focus on the notifications that are most important to them.

Refer to the official documentation for more details.

The below-mentioned APIs are supported from SDK version 12.3.01

When the application is running on Android 13 to show notifications to the user, applications would need to request the user for notification permission.

For applications integrating the MoEngage SDK, would need to 

  • Notify the SDK of the permission request's response from the user.
  • If the application has already requested for the push permission(before MoEngage integration) help MoEngage setup notification channels for notification display.

Notify SDK of permission result

Once the application requests the user for notification permission notify the SDK of the user response using the below API.

Kotlin Java

    MoEPushHelper.getInstance().pushPermissionResponse(applicationContext, isGranted)

Setup Notification Channels

If the application has already taken notification permission from the user call the below API to set up Notification Channels for showing push notifications.

Kotlin Java

    MoEPushHelper.getInstance().setUpNotificationChannels(context)

MoEngage SDK provides helper APIs to show the permission request to the end-user or navigate the user to the settings screen for enabling notifications.

Use the below API to show the permission request dialog to the user.

When using the below API SDK automatically tracks the response, sets up the required notification channel, etc, mentioned above.

Kotlin Java

    MoEPushHelper.getInstance().requestPushPermission(activity)

Use the below API to show navigate the user to the Notification Settings for the application on the device.

Note: Below Android 8(API level 26) the user is directed to the Application Info screen of your application.

Kotlin Java

    MoEPushHelper.getInstance().navigateToSettings(activity)

 

Was this article helpful?
0 out of 1 found this helpful