Configure push notification style
When a push message is received, the system displays a notification.
- FCM push: For FCM push, if the Push Method in the console is set to Data Message, you can customize the notification style using the method below.
- Other third-party push providers: After the SDK receives a push notification from other third-party providers, the displayed notification is a system notification popped up directly by the underlying OS, so customization is not supported.
Customize notification style
If you use FCM push and the FCM Push Method in the console is configured as Data Message, customize the notification style through PushMessageReceiver.onNotificationMessageArrived().
Using PushMessageReceiver
tip
Due to Android 12 notification trampoline restrictions, if your app's targetVersion ≥ 31, launch the Activity directly inside the PushMessageReceiver callback. Do not dispatch the message through a broadcast or service before launching the Activity.
- Create a custom
YourCustomPushMessageReceiverclass that extendsPushMessageReceiver. OverrideonNotificationMessageArrived(...)to intercept the incoming FCM data message and apply your custom notification display logic.
Example
Java
public class YourCustomMessageReceiver extends PushMessageReceiver {
// Override onNotificationMessageArrived(...) here.
}
-
Register your custom push broadcast receiver in the main project's
AndroidManifest.xml. Replace the existingPushMessageReceiverregistration entry.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>