tencent cloud

フィードバック

Android

最終更新日:2024-05-08 11:37:24
    This document describes how to replace the incoming call ringtone of TUICallKit, which is divided into application ringtone and offline push ringtone.

    I. Setting Application Ringtone

    There are two ways to set the application ringtone: replace the ringtone audio, or call the Setting Ringtone API.

    1. Replace Audio File

    If you include the TUICallKit component through source code dependency, you can achieve the goal of replacing the ringtone by changing the three audio files under the res\\raw folder:
    File Name
    Purpose
    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. Set Ringtone API

    You can also use the setCallingBell API to set the incoming call ringtone.
    Kotlin
    Java
    TUICallKit.createInstance(context).setCallingBell(filePath)
    TUICallKit.createInstance(context).setCallingBell(filePath);

    3. Setting Mute Mode

    If you do not require a ringtone, you can use enableMuteMode to set the mute mode.
    Kotlin
    Java
    TUICallKit.createInstance(context).enableMuteMode(true)
    TUICallKit.createInstance(context).enableMuteMode(true);

    II. Setting Offline Push Ringtone

    Offline notification ringtones only support customization from the following manufacturers: Huawei, Xiaomi, FCM, and APNs. Other manufacturers like OPPO, VIVO, Honor, etc., are not supported at this time.
    TUICallKit introduces the TUIOfflinePush component. It requires calling the following method at application launch to enable custom offline notification ringtone capabilities.
    Kotlin
    Java
    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

    Call the APIs including setAndroidSound() and setIOSSound().
    Customize Ringtone Resource File, add the ringtone file to the local Android Studio project's res/raw directory.
    Kotlin
    Java
    val pushInfo = OfflinePushInfo()
    pushInfo.iosSound = "Ring Tone Name.mp3"
    pushInfo.androidSound = "Ring Tone Name"
    TUICallDefine.OfflinePushInfo pushInfo = new TUICallDefine.OfflinePushInfo();
    pushInfo.setIOSSound("Ring Tone Name.mp3");
    pushInfo.setAndroidSound("Ring Tone Name");
    Caution
    Supported in IMSDK v6.1.2155 and later versions.
    The ringtone for Huawei mobile phone push messages is the one set when the notification channel is first created. Setting a different ringtone later is ineffective. If you wish to update the custom notification ringtone, you need to uninstall and reinstall. For more details, see: Huawei Custom Ringtone.

    2, Xiaomi

    (1) For versions earlier than Android 8.0, use setAndroidSound() and setIOSSound() to customize the ringtone resource file. Add the ringtone file to the project's res/raw directory (refer to the above Huawei invocation).
    (2) For versions later than Android 8.0, you also need to sign in to the Xiaomi Vendor Console and create a channel and configure it, where the ringtone file must be added to the local Android Studio project's res/raw directory.
    Kotlin
    Java
    val pushInfo = OfflinePushInfo()
    pushInfo.iosSound = "Ring Tone 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");
    Caution
    For pre-Android 8.0 methods, supported in IMSDK v6.1.2155 and later versions.
    For post-Android 8.0 methods, supported in IMSDK v7.0.3754 and later versions.

    3,FCM

    (1) For versions earlier than Android 8.0, use setAndroidSound() and setIOSSound() to customize the ringtone resource file. Add the ringtone file to the project's res/raw directory (refer to the above Huawei invocation).
    (2) For versions later than 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 your local Android Studio project's res/raw directory, specifying the ringtone name and channel ID name, see PrivateConstants.
    public class PrivateConstants {
    // For FCM channels, specify the channel ID
    public static String fcmPushChannelId = "FCM ChannelID";
    // FCM requires specifying the push ringtone name for the channel, consistent with the ringtone file name in the Android Studio project's res/raw directory, no suffix is required
    public static String fcmPushChannelSoundName = "Ring Tone Name";
    }
    Kotlin
    Java
    val pushInfo = OfflinePushInfo()
    pushInfo.iosSound = "Ring Tone 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 ChannelID");
    Caution
    For pre-Android 8.0 methods, supported in IMSDK v6.1.2155 and later versions.
    For post-Android 8.0 methods, supported in IMSDK v7.0.3754 and later versions.
    FCM custom ringtone or Setting ChannelID is only supported in Certificate Mode.
    お問い合わせ

    カスタマーサービスをご提供できるため、ぜひお気軽にお問い合わせくださいませ。

    テクニカルサポート

    さらにサポートが必要な場合は、サポートチケットを送信して弊社サポートチームにお問い合わせください。24時間365日のサポートをご提供します。

    電話サポート(24 時間365日対応)