This article explains how to replace the incoming call ringtone in TUICallKit. The incoming call ringtone is divided into application ringtone and offline push ringtone.
Setting the application ringtone
There are two methods to set the application ringtone: replace ringtone audio, call Setting ringtone interface.
1. Replace Audio File
If you integrate the TUICallKit component via source code dependency, you can replace the three audio files in the res\\raw
folder to achieve the goal of replacing the ringtone:
|
phone_dialing.mp3 | Ringtone when initiating a call |
phone_hangup.mp3 | Ringtone when the call is disconnected |
phone_ringing.mp3 | Ringtone when receiving a call |
2. Setting Ringtone Interface
You can also customize the incoming call ringtone through the setCallingBell interface.
TUICallKit.createInstance(context).setCallingBell(filePath)
TUICallKit.createInstance(context).setCallingBell(filePath);
3. Setting Mute Mode
If you do not need the phone to ring, you can enable the mute mode using the enableMuteMode setting.
TUICallKit.createInstance(context).enableMuteMode(true)
TUICallKit.createInstance(context).enableMuteMode(true);
Setting Offline Push Ringtone
Offline notification ringtones only support the following manufacturers for custom definitions: Huawei, Xiaomi, FCM, and APNs; other manufacturers such as OPPO, VIVO, Honor, etc., are not supported currently.
TUICallKit has introduced the TUIOfflinePush component. To enable offline notification custom ringtone capability, call the following method during application launch.
class DemoApplication : Application() {
override fun onCreate() {
TUIOfflinePushConfig.getInstance().isAndroidPrivateRing = true
}
}
public class DemoApplication extends Application {
@Override
public void onCreate() {
TUIOfflinePushConfig.getInstance().setAndroidPrivateRing(true);
}
}
1. Huawei & APNs
Invoke the interfaces setAndroidSound() and setIOSSound().
Customize the ringtone resource files, add the ringtone files to the local Android Studio project in the res/raw directory.
val pushInfo = OfflinePushInfo()
pushInfo.iosSound = "ringtone name.mp3"
pushInfo.androidSound = "Ring Tone Name"
TUICallDefine.OfflinePushInfo pushInfo = new TUICallDefine.OfflinePushInfo();
pushInfo.setIOSSound("Ring Tone Name.mp3");
pushInfo.setAndroidSound("Ring Tone Name");
Note
The IMSDK version 6.1.2155 and subsequent versions are supported.
The ringtone of Huawei's push message corresponds to the ringtone when the notification channel is first created, and subsequent settings for other ringtones do not take effect. If you want to update the user-defined notification ringtone, the application must be uninstalled and reinstalled. For details, see: Custom Ringtones on Huawei. 2. Xiaomi
(1) Before Android 8.0, use setAndroidSound() and setIOSSound() to customize the ringtone resource file by adding the ringtone file to the project's res/raw directory (refer to the Huawei invocation mentioned above).
(2) After Android 8.0, it's also necessary to sign in to the Mi Vendor Console and create a channel and configure it, where the ringtone file needs to be added to the res/raw directory of the local Android Studio project. val pushInfo = OfflinePushInfo()
pushInfo.iosSound = "ringtone name.mp3"
pushInfo.androidSound = "Ring Tone Name"
pushInfo.androidXiaoMiChannelID = "Vendor Requested Channel ID"
TUICallDefine.OfflinePushInfo pushInfo = new TUICallDefine.OfflinePushInfo();
pushInfo.setIOSSound("Ring Tone Name.mp3");
pushInfo.setAndroidSound("Ring Tone Name");
pushInfo.setAndroidXiaoMiChannelID("Vendor Requested Channel ID");
Note
For versions before Android 8.0, supported by IMSDK version 6.1.2155 and above.
For versions after Android 8.0, supported by IMSDK version 7.0.3754 and above.
3. FCM
(1) Before Android 8.0, use setAndroidSound() and setIOSSound() to customize the ringtone resource file by adding the ringtone file to the project's res/raw directory (refer to the Huawei invocation mentioned above).
(2) After Android 8.0, FCM requires a configuration of channelID and ringtone resources. The tuiofflinepush component introduced by TUICallKit has already handled the playback of custom ringtones. The ringtone file needs to be added to the res/raw directory of your local Android Studio project, and the names of the ringtone and channel ID need to be specified. See PrivateConstants for more details. public class PrivateConstants {
public static String fcmPushChannelId = "FCM ChannelID";
public static String fcmPushChannelSoundName = "ringtone name";
}
val pushInfo = OfflinePushInfo()
pushInfo.iosSound = "ringtone name.mp3"
pushInfo.androidSound = "Ring Tone Name"
pushInfo.androidFCMChannelID = "Vendor Requested Channel ID"
TUICallDefine.OfflinePushInfo pushInfo = new TUICallDefine.OfflinePushInfo();
pushInfo.setIOSSound("Ring Tone Name.mp3");
pushInfo.setAndroidSound("Ring Tone Name");
pushInfo.setAndroidFCMChannelID("Vendor Requested Channel ID");
Note
For versions before Android 8.0, supported by IMSDK version 6.1.2155 and above.
For versions after Android 8.0, supported by IMSDK version 7.0.3754 and above.
FCM custom ringtone definition or setting channel id only supports certificate mode.
Was this page helpful?