tencent cloud

文档反馈

最后更新时间:2024-09-06 16:41:34
    本文介绍如何替换 TUICallKit 的来电铃声,来电铃声分为应用铃声离线推送铃声

    设置应用铃声

    设置应用铃声有两种方式:

    1、替换默认的铃声资源

    如果您通过源码依赖 TUICallKit 组件,您可以替换 Resources\\AudioFile 文件夹下的音频文件来达到替换铃声的目的:
    文件名
    用途
    phone_dialing.mp3
    发起呼叫时的铃音
    phone_ringing.mp3
    接到呼叫时的铃音

    2、设置铃声接口

    您也可以通过 setCallingBell 接口设置被叫端收到的来电铃声
    Swift
    Objective-C
    import TUICallKit_Swift
    
    TUICallKit.createInstance().setCallingBell(filePath: "")
    #import <TUICallKit_Swift/TUICallKit_Swift-Swift.h>
    
    [[TUICallKit createInstance] setCallingBellWithFilePath:@""];

    设置静音模式

    如果您的被叫端收到邀请,不需要响铃您可以通过 enableMuteMode 设置静音模式。
    Swift
    Objective-C
    import TUICallKit_Swift
    
    TUICallKit.createInstance().enableMuteMode(enable: true)
    #import <TUICallKit_Swift/TUICallKit_Swift-Swift.h>
    
    [[TUICallKit createInstance] enableMuteModeWithEnable:YES];

    设置离线推送铃音

    VoIP 推送不支持自定义推送铃声。 APNs 推送可以在调用 call 接口拨打电话时设置 params 的 offlinePushInfo 中的 iOSSound 字段, iOSSound 传语音文件名。
    注意:
    离线推送声音设置(仅对 iOS 生效),如果要自定义 iOSSound,需要先把语音文件链接进 Xcode 工程,然后把语音文件名(带后缀名)设置给 iOSSound。
    铃声时长应小于30s。
    Swift
    Objective-C
    import TUICallKit_Swift
    import TUICallEngine
    
    let pushInfo: TUIOfflinePushInfo = TUIOfflinePushInfo()
    pushInfo.title = ""
    pushInfo.desc = "您有一个新的通话"
    pushInfo.iOSPushType = .apns
    pushInfo.ignoreIOSBadge = false
    pushInfo.iOSSound = "phone_ringing.mp3"
    pushInfo.androidSound = "phone_ringing"
    // OPPO必须设置ChannelID才可以收到推送消息,这个channelID需要和控制台一致
    // OPPO must set a ChannelID to receive push messages. This channelID needs to be the same as the console.
    pushInfo.androidOPPOChannelID = "tuikit"
    // FCM channel ID, you need change PrivateConstants.java and set "fcmPushChannelId"
    pushInfo.androidFCMChannelID = "fcm_push_channel"
    // VIVO message type: 0-push message, 1-System message(have a higher delivery rate)
    pushInfo.androidVIVOClassification = 1
    // HuaWei message type: https://developer.huawei.com/consumer/cn/doc/development/HMSCore-Guides/message-classification-0000001149358835
    pushInfo.androidHuaWeiCategory = "IM"
    
    let params = TUICallParams()
    params.userData = "User Data"
    params.timeout = 30
    params.offlinePushInfo = pushInfo
    
    TUICallKit.createInstance().call(userId: "123456", callMediaType: .audio, params: params) {
    
    } fail: { code, message in
    
    }
    #import <TUICallKit_Swift/TUICallKit_Swift-Swift.h>
    #import <TUICallEngine/TUICallEngine.h>
    
    - (TUICallParams *)getCallParams {
    TUIOfflinePushInfo *offlinePushInfo = [self createOfflinePushInfo];
    TUICallParams *callParams = [TUICallParams new];
    callParams.offlinePushInfo = offlinePushInfo;
    callParams.timeout = 30;
    return callParams;
    }
    
    - (TUIOfflinePushInfo *)createOfflinePushInfo {
    TUIOfflinePushInfo *pushInfo = [TUIOfflinePushInfo new];
    pushInfo.title = @"";
    pushInfo.desc = @"您有一个新的通话";
    pushInfo.iOSPushType = TUICallIOSOfflinePushTypeAPNs;
    pushInfo.ignoreIOSBadge = NO;
    pushInfo.iOSSound = @"phone_ringing.mp3";
    pushInfo.AndroidSound = @"phone_ringing";
    // OPPO必须设置ChannelID才可以收到推送消息,这个channelID需要和控制台一致
    // OPPO must set a ChannelID to receive push messages. This channelID needs to be the same as the console.
    pushInfo.AndroidOPPOChannelID = @"tuikit";
    // FCM channel ID, you need change PrivateConstants.java and set "fcmPushChannelId"
    pushInfo.AndroidFCMChannelID = @"fcm_push_channel";
    // VIVO message type: 0-push message, 1-System message(have a higher delivery rate)
    pushInfo.AndroidVIVOClassification = 1;
    // HuaWei message type: https://developer.huawei.com/consumer/cn/doc/development/HMSCore-Guides/message-classification-0000001149358835
    pushInfo.AndroidHuaWeiCategory = @"IM";
    return pushInfo;
    }
    
    [[TUICallKit createInstance] callWithUserId:@"123456"
    callMediaType:TUICallMediaTypeAudio
    params:[self getCallParams] succ:^{
    
    } fail:^(int code, NSString * _Nullable errMsg) {
    
    }];
    联系我们

    联系我们,为您的业务提供专属服务。

    技术支持

    如果你想寻求进一步的帮助,通过工单与我们进行联络。我们提供7x24的工单服务。

    7x24 电话支持