Configure Push Notification Ringtone
Remote push notification ringtones refer to the ringtones played when receiving notifications from the push channel. The app will only receive offline push notifications when it is in a closed state. By default, the sound and vibration alert settings of the mobile phone system are used.
Remote push notifications will not be triggered when the app is in the background and has not been reclaimed by the system.
RC currently supports configuring custom ringtones for specified message types, and has adapted to Xiaomi Push, Huawei Push (only overseas), and FCM Push.
Select Message Type
First, confirm the unique identifier (Object Name) of the message content type for which you want to customize the ringtone. For queries, refer to Message Type Overview.
Prepare Ringtone Resource Files
You need to package the custom sound resource file name into the application. When users receive push messages of this type, the set file will be automatically read for sound alerts. Below are the path requirements for each manufacturer:
- Xiaomi Push:
android.resource://<package-name>/raw/<filename>
, where<package-name>
should be replaced with your application package name.<filename>
should be replaced with the ringtone file name without the extension (the stored sound file needs to have an extension, but do not write the extension in the uri). - Huawei Push:
/res/raw/
. - FCM Push:
/res/raw/
Create Channel ID
Create a custom notification channel. This Channel ID needs to be configured when setting up custom push ringtones in the console.
Xiaomi Push
For Xiaomi phones with Android 8.0 and above, a Channel must be set up before customizing push ringtones. For details, refer to Xiaomi Push Development Documentation. Once a Channel is created and a message with the Channel is sent, this Channel will be generated on the device and cannot be deleted or modified, so please create Channels carefully.
Please refer to Xiaomi's documentation to create a Channel ID:
- Create Channel ID on Xiaomi Open Platform
- Create Channel ID using Xiaomi Server API
- Create Channel ID using Xiaomi Push Server SDK (Only the Xiaomi Push Server Java SDK documentation link is provided here. For other languages, please refer to Xiaomi Push official documentation.)
Huawei Push
Due to Huawei platform restrictions, when the data processing location is set to China on the Huawei platform, custom channels are not supported, and custom ringtones cannot be used. Other regions support setting custom ringtones after registering the Channel ID.
The app calls the Android SDK interface to create a push notification channel exclusive to the application. Initialization can be done in MainActivity or Application. The specific code example is as follows:
private void initNotificationChannel() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
//Add ringtone channel, you can choose the audio file in the resource file
String channelIdKanong = "NotificationKanong";
String channelNameKanong = "RingtoneKanong";
createNotificationChannel(channelIdKanong, channelNameKanong, importance, R.raw.kanong);
}
//Create notification channel
@RequiresApi(api = Build.VERSION_CODES.O)
private void createNotificationChannel(String channelId, String channelName, int importance, int rawSource) {
NotificationChannel channel = new NotificationChannel(channelId, channelName, importance);
if (rawSource != 0) {
// The stored sound file needs to have an extension, but do not write the extension in the uri
String uriStr = "android.resource://" + this.getPackageName() + "/" + rawSource;
Uri uri = Uri.parse(uriStr);
channel.setSound(uri, Notification.AUDIO_ATTRIBUTES_DEFAULT);
}
NotificationManager notificationManager = (NotificationManager) getSystemService(
NOTIFICATION_SERVICE);
notificationManager.createNotificationChannel(channel);
}
}
FCM Push
Refer to the official Android documentation Notification Channels and FCM Push Development Documentation.
Configure Ringtone for Message Type
After confirming that the ringtone resource file has been packaged into the application, you need to configure the corresponding custom push ringtone by message type and Channel ID in the RC console. Currently, the console supports setting up Xiaomi Push, Huawei Push, and FCM Push. Up to 5 custom ringtones can be set under each push manufacturer, and the settings will take effect after 30 minutes.
-
Visit the RC console Custom Push Ringtone page, and click Add under the Xiaomi, Huawei, and FCM tabs.
-
Select the ApplicationID, enter the Channel ID, message type name, and the custom ringtone file resource address. Take configuring Xiaomi custom push ringtone as an example:
After successful setup, all Xiaomi phone users in the offline state will receive push notifications for this type of message using the set Channel ID, and the alert ringtone will be the custom ringtone set when registering the Channel.