Basic Setup
Follow the basic setup outlined in this section to enable push notifications on an Android device using MoEngage.- FCM Setup on MoEngage Dashboard - FCM Authentication is the method to enable sending push notifications to your app installed on Android devices. Use the methods mentioned in this article to authenticate MoEngage to access Firebase services.
- Adding metadata for push notification - Set the small icon and large icon drawable and other options to handle push notifications using the methods available in this article.
- Android Notification Runtime Permissions - When the application is running on Android 13 to show notifications to the user, applications would need to request the user for notification permission. Refer to the methods available in this article to handle permission requests.
- Push Registration and Receiving - To use Push Notification in your React Native application, you must configure Firebase. Configuring Firebase steps will depend on how you want to integrate it. MoEngage recommends leaving the push handling to MoEngage SDK, as the best practices are properly integrated. You can also handle the push at your app level. In any case, look at the following section that applies to you and finish the integration steps.
- Let MoEngage handle Push(Recommended)
- You handle Push via Android Native
- You handle Push via React Native (Not Recommended)
Add messaging service
You must add the messaging service to the Manifest file for MoEngage SDK to show the notifications. Refer to this document here.Callback on token registration (optional)
To get a callback whenever a new token is registered or refreshed, refer to the method here.Notification Clicked CallbackTo receive a callback whenever a push is clicked and for custom handling redirection, use the method in this article.
You must add the messaging service to the Manifest file for MoEngage SDK to show the notifications. Refer to this document here.Callback on token registration (optional)
To get a callback whenever a new token is registered or refreshed, refer to the method here.Notification Clicked CallbackTo receive a callback whenever a push is clicked and for custom handling redirection, use the method in this article.
React-Native methods for Push
You can skip this section completely if you let MoEngage handle push token registration and display or use Android Native methods to pass tokens and payload to MoEngage SDKs. Read on if you want to use React Native methods of MoEngage SDK to pass the Firebase Installation ID and payload to MoEngage SDKs.Passing the Firebase Installation ID
The SDK registers devices for push using the Firebase Installation ID. Pass the installation ID withpassFirebaseInstallationId():