Customize push notification style
When the app receives a push notification, the system displays a notification. You can customize the notification appearance depending on the push provider:
- FCM push: If the push method is set to data message in the Console, you can customize the notification style using the method below.
- Other push providers: Notifications from other vendor push providers are system-level notifications displayed directly by the OS. Customization is not supported.
Customize notification style
If you use FCM push and the push method is set to data message in the Console, customize the notification style through PushMessageReceiver.onNotificationMessageArrived().
Use PushMessageReceiver
Use PushMessageReceiver.onNotificationMessageArrived() to intercept the incoming FCM data message and apply your custom notification display logic.
Due to Android 12 notification trampoline restrictions, if your app targets API level 31 or higher, start the Activity directly in the PushMessageReceiver callback. Do not route through a broadcast or service before launching the Activity.
-
Create a custom
YourCustomPushMessageReceiverthat extendsPushMessageReceiver. UseonNotificationMessageArrivedto receive push content.Example
- Kotlin
- Java
kotlinclass YourCustomMessageReceiver : PushMessageReceiver() {
// Override onNotificationMessageArrived(...) here.
}Javapublic class YourCustomMessageReceiver extends PushMessageReceiver {
// Override onNotificationMessageArrived(...) here.
} -
Register your custom receiver in the app's
AndroidManifest.xml. Replace any existingPushMessageReceiverregistration.xml<receiver
android:name="xxx.YourCustomPushMessageReceiver"
android:exported="true">
<intent-filter>
<action android:name="io.rong.push.intent.MESSAGE_ARRIVED" />
<action android:name="io.rong.push.intent.MESSAGE_CLICKED" />
<action android:name="io.rong.push.intent.THIRD_PARTY_PUSH_STATE" />
</intent-filter>
</receiver>