Vendor | Custom ringtone support |
iOS | Supported |
FCM | Supported |
raw directory of the Android project or link it to the Xcode project for iOS.{// ..."OfflinePushInfo": {"AndroidInfo": {"Sound": "shake" // Without the filename extension},"ApnsInfo": {"Sound": "apns.caf",}}}
V2TIMOfflinePushInfo v2TIMOfflinePushInfo = new V2TIMOfflinePushInfo();v2TIMOfflinePushInfo.setAndroidSound("ringtone_name");v2TIMOfflinePushInfo.setIOSSound("ringtone_name.mp3");String msgID = V2TIMManager.getMessageManager().sendMessage(v2TIMMessage, isGroup ? null : userID, isGroup ? groupID : null,V2TIMMessage.V2TIM_PRIORITY_DEFAULT, false, v2TIMOfflinePushInfo, new V2TIMSendCallback<V2TIMMessage>() {@Overridepublic void onProgress(int progress) {}@Overridepublic void onError(int code, String desc) {}@Overridepublic void onSuccess(V2TIMMessage v2TIMMessage) {}});
raw directory of the project resources, and then create a notification channel as follows.// Custom channel creation exampleif (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {NotificationManager nm = (NotificationManager) context.getSystemService(context.NOTIFICATION_SERVICE);NotificationChannel notificationChannel =new NotificationChannel("channelId", "channelName", NotificationManager.IMPORTANCE_HIGH);notificationChannel.enableLights(true);notificationChannel.enableVibration(true);notificationChannel.setShowBadge(true);notificationChannel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);// "android.resource://package_name/raw/private_ring"notificationChannel.setSound(Uri.parse("sound"), null);nm.createNotificationChannel(notificationChannel);}
channelID when sending a message.{// ..."OfflinePushInfo": {"AndroidInfo": {"GoogleChannelID": "test_Google_channel_id",}}}
V2TIMOfflinePushInfo v2TIMOfflinePushInfo = new V2TIMOfflinePushInfo();v2TIMOfflinePushInfo.setAndroidFCMChannelID(PrivateConstants.fcmPushChannelId);String msgID = V2TIMManager.getMessageManager().sendMessage(v2TIMMessage, isGroup ? null : userID, isGroup ? groupID : null,V2TIMMessage.V2TIM_PRIORITY_DEFAULT, false, v2TIMOfflinePushInfo, new V2TIMSendCallback<V2TIMMessage>() {@Overridepublic void onProgress(int progress) {TUIChatUtils.callbackOnProgress(callBack, progress);}@Overridepublic void onError(int code, String desc) {TUIChatUtils.callbackOnError(callBack, TAG, code, desc);}@Overridepublic void onSuccess(V2TIMMessage v2TIMMessage) {}});
GoogleChannelID field for FCM is supported only in Chat SDK 7.0.3754 or later.ChannelID configuration are supported only in certificate mode.iOSSound field in OfflinePushInfo to the name of the sound file.{// ..."OfflinePushInfo": {"ApnsInfo": {"Sound": "apns.caf"}}}
V2TIMOfflinePushInfo *pushInfo = [[V2TIMOfflinePushInfo alloc] init];pushInfo.title = @"push title";pushInfo.iOSSound = @"phone_ringing.caf"; // your voice file's name[[V2TIMManager sharedInstance] sendMessage:msg receiver:receiver groupID:groupID priority:V2TIM_PRIORITY_DEFAULT onlineUserOnly:NO offlinePushInfo:pushInfo progress:nil succ:^{} fail:^(int code, NSString *msg) {}];
iOSSound = kIOSOfflinePushNoSound, no sound is played when the notification is received.iOSSound = kIOSOfflinePushDefaultSound, the system sound is played when the notification is received.iOSSound, first link the sound file to the Xcode project, and then set iOSSound to the sound filename, including its filename extension.AndroidSound field in OfflinePushInfo to the name of the sound file.{"OfflinePushInfo": {"AndroidInfo": {"Sound": "shake", // Without the filename extension"XiaoMiChannelID": "test_XiaoMi_channel_id","OPPOChannelID": "test_OPPO_channel_id","GoogleChannelID": "test_Google_channel_id"},"ApnsInfo": {"Sound": "apns.caf"}}}
V2TIMOfflinePushInfo *pushInfo = [[V2TIMOfflinePushInfo alloc] init];pushInfo.title = @"push title";pushInfo.AndroidSound = @"phone_ringing"; // your voice file's name[[V2TIMManager sharedInstance] sendMessage:msg receiver:receiver groupID:groupID priority:V2TIM_PRIORITY_DEFAULT onlineUserOnly:NO offlinePushInfo:pushInfo progress:nil succ:^{} fail:^(int code, NSString *msg) {}];
raw directory of the Android project or link it to the Xcode project for iOS.iOSSound and androidSound fields in offlinePushInfo.{// ..."OfflinePushInfo": {"AndroidInfo": {"Sound": "shake", // Without the filename extension"XiaoMiChannelID": "test_XiaoMi_channel_id","OPPOChannelID": "test_OPPO_channel_id","GoogleChannelID": "test_Google_channel_id"},"ApnsInfo": {"Sound": "apns.caf"}}}
iOSSound and androidSound fields in offlinePushInfo when calling sendMessage.
App.vue, as shown below:import * as Push from '@/uni_modules/TencentCloud-Push';Push.createNotificationChannel({channelID: '', // ID of the custom channel. For OPPO, use the channelID configured in the console.channelName: 'custom channel', // Name of the custom channelchannelDesc: 'This is a description', // Description of the custom channelchannelSound: 'private_ring' // Name of the custom ringtone, without the filename extension}, () => {console.log('Push | createNotificationChannel ok');})
nativeResources/ios/Resources directory, as shown below:
npm install @tencentcloud/chat@latest
TencentCloudChat.VERSION value in the browser console to confirm that @tencentcloud/chat is 3.3.2 or later, as shown below:
TencentCloudChat.VERSION value in the HBuilder logs to confirm that @tencentcloud/chat is 3.3.2 or later, as shown below:
TencentCloudChat.VERSION value in the Mini Program Developer Tools console to confirm that @tencentcloud/chat is 3.3.2 or later, as shown below:
offlinePushInfoandroidInfo.FCMChannelID.apnsInfo.sound = TUIChatEngine.TYPES.IOS_OFFLINE_PUSH_NO_SOUND, no sound is played when the notification is received.apnsInfo.sound = TUIChatEngine.TYPES.IOS_OFFLINE_PUSH_DEFAULT_SOUND, the system sound is played when the notification is received.TUIChatService in UIKit to send a message, configure the relevant offlinePushInfo parameters. The following example sends a text message:// Send a text messagelet promise = TUIChatService.sendTextMessage({payload: { text: 'Hello world!' }},{// If the recipient is offline, the message is stored for roaming and an offline push notification is sent when the recipient's app is in the background or its process has been killed. You can customize the title and content of the offline push notification.offlinePushInfo: {androidInfo: { // Android push configurationsound: 'private_ring.mp3', // Android custom ringtoneXiaoMiChannelID: '', // Required on Xiaomi devices running Android 8.0 or laterFCMChannelID: '', // Required to configure notification sounds for FCM on Google devices running Android 8.0 or laterOPPOChannelID: '', // Required on OPPO devices},apnsInfo: { // APNs push configuration// apnsInfo.sound = TUIChatEngine.TYPES.IOS_OFFLINE_PUSH_NO_SOUND: no sound is played when the notification is received.// apnsInfo.sound = TUIChatEngine.TYPES.IOS_OFFLINE_PUSH_DEFAULT_SOUND: the system sound is played when the notification is received.sound: 'private_ring.caf', // iOS custom ringtone}}});promise.catch((error) => {// If an exception occurs, catch it with promise.catch for error handling.});
apnsInfo.sound = TencentCloudChat.TYPES.IOS_OFFLINE_PUSH_NO_SOUND, no sound is played when the notification is received.apnsInfo.sound = TencentCloudChat.TYPES.IOS_OFFLINE_PUSH_DEFAULT_SOUND, the system sound is played when the notification is received.offlinePushInfo fields as follows:// Message sending optionschat.sendMessage(message, {// If the recipient is offline, the message is stored for roaming and an offline push notification is sent when the recipient's app is in the background or its process has been killed. You can customize the title and content of the offline push notification.offlinePushInfo: {androidInfo: { // Android push configurationsound: 'private_ring.mp3', // Android custom ringtoneXiaoMiChannelID: '', // Required on Xiaomi devices running Android 8.0 or laterFCMChannelID: '', // Required to configure notification sounds for FCM on Google devices running Android 8.0 or laterOPPOChannelID: '', // Required on OPPO devices},apnsInfo: { // APNs push configuration// apnsInfo.sound = TencentCloudChat.TYPES.IOS_OFFLINE_PUSH_NO_SOUND: no sound is played when the notification is received.// apnsInfo.sound = TencentCloudChat.TYPES.IOS_OFFLINE_PUSH_DEFAULT_SOUND: the system sound is played when the notification is received.sound: 'private_ring.caf', // iOS custom ringtone}}});
androidSound is the ringtone filename without the filename extension.iOSSound is the ringtone filename with the filename extension.const TUICallKit = uni.requireNativePlugin('TencentCloud-TUICallKit');const options = {userID: '',callMediaType: 1, // Audio call (callMediaType = 1) or video call (callMediaType = 2)callParams: {// If the recipient is offline, an offline push notification is sent when the recipient's app is in the background or its process has been killed. You can customize the title and content of the offline push notification.offlinePushInfo: {title: 'test-title',description: 'you have a test call',androidSound: 'private_ring', // Custom ringtone for Android offline pushiOSSound: 'private_ring.caf', // Custom ringtone for iOS offline push},},};TUICallKit.call(options, (res) => {if (res.code === 0) {console.log('call success');} else {console.log(`call failed, error message = ${res.msg}`);}});

MyReactNativeApp/ios/MyReactNativeApp/Resources directory. Open the MyReactNativeApp project in Xcode, right-click the project, choose Add Files to "MyReactNativeApp", and add the ringtone file to the project, as shown below:Project | Xcode |
![]() | ![]() |
offlinePushInfo.apnsInfo.sound = TencentCloudChat.TYPES.IOS_OFFLINE_PUSH_NO_SOUND, no sound is played when the notification is received.apnsInfo.sound = TencentCloudChat.TYPES.IOS_OFFLINE_PUSH_DEFAULT_SOUND, the system sound is played when the notification is received.// Message sending optionschat.sendMessage(message, {// If the recipient is offline, the message is stored for roaming and an offline push notification is sent when the recipient's app is in the background or its process has been killed. You can customize the title and content of the offline push notification.offlinePushInfo: {androidInfo: { // Android push configurationsound: 'private_ring.mp3', // Android custom ringtoneXiaoMiChannelID: '', // Required on Xiaomi devices running Android 8.0 or laterFCMChannelID: '', // Required to configure notification sounds for FCM on Google devices running Android 8.0 or laterOPPOChannelID: '', // Required on OPPO devices},apnsInfo: { // APNs push configuration// apnsInfo.sound = TencentCloudChat.TYPES.IOS_OFFLINE_PUSH_NO_SOUND: no sound is played when the notification is received.// apnsInfo.sound = TencentCloudChat.TYPES.IOS_OFFLINE_PUSH_DEFAULT_SOUND: the system sound is played when the notification is received.sound: 'private_ring.caf', // iOS custom ringtone}}});

import Push from "@tencentcloud/donut-push"App({onLaunch: function () {Push.createNotificationChannel({channelID: "", // ID of the custom channelchannelName: "", // Name of the custom channelchannelDesc: "", // Description of the custom channelchannelSound: "" // Name of the custom ringtone file, without the filename extension}).then((ret) => {console.info("createNotificationChannel success", ret);}).catch((ret) => {console.error("createNotificationChannel failed", ret);});}})


{"From_Account": "administrator","To_Account": ["100480"],"MsgRandom": 3674128,"OfflinePushInfo": {"PushFlag": 0,"Title": "Offline push title 1adad1","Desc": "Offline push content 11adasd1","Ext":"{\\"aa\\":12123}","AndroidInfo": {"Sound": "private_ring123", // Must match the ringtone filename in the channel created on the client"OPPOChannelID": "test_oppo_channel_id","XiaoMiChannelID": "test_xiaomi_channel_id","GoogleChannelID": "test_google_channel_id"},"ApnsInfo": {"Sound": "01.caf"// Must match the ringtone filename in the receiving client's IPA}}}
Apakah halaman ini membantu?
Anda juga dapat Menghubungi Penjualan atau Mengirimkan Tiket untuk meminta bantuan.
masukan