离线唤醒功能,能够让您的 App 在后台运行或者离线状态下依然能够收到音视频通话的响铃呼叫,TUICallKit Flutter 需要依赖厂商: Apple、Google、Vivo、Xiaomi 提供的推送能力来进行消息通知。
配置离线推送
1. iOS
iOS 平台的离线唤醒支持APNs
和VoIP
具体配置流程请参考:
2. Android
自定义离线消息内容
在基础的离线推送配置成功后,您就可以正常收到对来电推送,如果您需要自定义离线消息的内容,可通过call
和 groupcall
接口中的参数 params
中的TUIOfflinePushInfo
实现自定义通知内容,可以自定义的内容包括标题、内容、离线消息铃声等内容。具体使用如下:
Future<void> call(String userId, TUICallMediaType callMediaType, [TUICallParams? params])
class TUICallParams {
TUIOfflinePushInfo offlinePushInfo;
}
class TUIOfflinePushInfo {
String? title;
String? desc;
bool? ignoreIOSBadge;
String? iOSSound;
String? androidSound;
String? androidOPPOChannelID;
int? androidVIVOClassification;
String? androidXiaoMiChannelID;
String? androidFCMChannelID;
String? androidHuaWeiCategory;
bool? isDisablePush;
TUICallIOSOfflinePushType? iOSPushType;
}}
enum TUICallIOSOfflinePushType {
APNs,
VoIP,
}
自定义离线消息铃声
1. iOS
修改call
和groupcall
接口中的参数params
中的TUIOfflinePushInfo.iOSSound
设置iOS
平台上的离线消息铃声。
2. Android
FCM
在完成第一步:配置离线推送之后,即可在离线的情况下收到消息推送,但是是默认的铃声,如果您需要支持自定义铃声,还需要进行如下操作: 1、 在IM 控制台-基础配置,选择 Android 原生离线推送配置 -> 选择 Google 的证书进行编辑,添加 ChannelID,如下图所示
2、在工程的 android/app/src/main/res/raw/
目录下,放入自定义的铃声文件,示例:"incoming_call.mp3'
3、在登录成功之后,通过 `tim_ui_kit_push_plugin` 插件 向 Android 系统注册播放自定义铃音的 NotificationChannel,示例代码如下
void createNotificationChannel() {
AndroidNotificationChannelGroup group = new AndroidNotificationChannelGroup("GroupID", "GroupName");
AndroidFlutterLocalNotificationsPlugin plugin = AndroidFlutterLocalNotificationsPlugin();
plugin.createNotificationChannelGroup(group);
AndroidNotificationChannel channel = AndroidNotificationChannel(
"fcm_push_channel", "ChannelName",
groupId: "GroupID",
importance: Importance.high,
enableLights: true,
enableVibration: true,
sound: RawResourceAndroidNotificationSound("incoming_call"));
plugin.createNotificationChannel(channel);
}
本页内容是否解决了您的问题?