{// ..."OfflinePushInfo": {"AndroidInfo": {"Sound": "shake", // without suffix},"ApnsInfo": {"Sound": "apns.mp3",}}}
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) {}});
// Custom 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);}
{// ..."OfflinePushInfo": {"AndroidInfo": {"OPPOChannelID": "test_OPPO_channel_id",}}}
{// ..."OfflinePushInfo": {"AndroidInfo": {"XiaoMiChannelID": "test_XiaoMi_channel_id",}}}
V2TIMOfflinePushInfo v2TIMOfflinePushInfo = new V2TIMOfflinePushInfo();v2TIMOfflinePushInfo.setAndroidXiaoMiChannelID("Channel ID Applied by Manufacturer");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) {}});
// Custom 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);}
{// ..."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) {}});
{// ..."OfflinePushInfo": {"ApnsInfo": {"Sound": "apns.mp3",}}}
V2TIMOfflinePushInfo *pushInfo = [[V2TIMOfflinePushInfo alloc] init];pushInfo.title = @"push title";pushInfo.iOSSound = @"phone_ringing.mp3"; // 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) {}];
AndroidSound
field of OfflinePushInfo when sending messages. Pass the voice file name to AndroidSound
.{"OfflinePushInfo": {"AndroidInfo": {"Sound": "shake", // without suffix"OPPOChannelID": "test_OPPO_channel_id","XiaoMiChannelID": "test_XiaoMi_channel_id","OPPOChannelID": "test_OPPO_channel_id","GoogleChannelID": "test_Google_channel_id"},"ApnsInfo": {"Sound": "apns.mp3"}}}
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) {}];
iOSSound
and androidSound
fields of offlinePushInfo when sending messages.{// ..."OfflinePushInfo": {"AndroidInfo": {"Sound": "shake", // without suffix"OPPOChannelID": "test_OPPO_channel_id","XiaoMiChannelID": "test_XiaoMi_channel_id","OPPOChannelID": "test_OPPO_channel_id","GoogleChannelID": "test_Google_channel_id"},"ApnsInfo": {"Sound": "apns.mp3"}}}
iOSSound
and androidSound
fields when calling sendMessage to send messages.
Was this page helpful?