Firebase Cloud Messaging (FCM)
提供的数据消息能力以及TUICallKit
组件,能够实现具有自定义布局的来电显示界面。TIMPush
插件,使用 FCM 的数据消息能力,实现音视频通话的横幅来电显示效果。应用在前台时的显示效果 | 应用在后台时或者离线时的显示效果 |
| |
google-services.json
文件 ,来实现离线推送功能。厂商推送平台 | Chat 控制台配置 |
| |
timpush-configs.json
文件添加到应用模块的 assets
目录下,将 google-services.json
添加到工程app目录下。下载文件 timpush-configs.json | 下载文件 google-services.json | 添加到工程 |
| | |
app/build.gradle
文件中添加如下依赖:implementation "com.tencent.timpush:timpush:latest.release"implementation "com.tencent.timpush:fcm:latest.release"
tuicallkit-kt/build.gradle
文件中修改 Chat SDK 的版本号。build.gradle
文件的 buildscript -> dependencies
下添加以下配置。buildscript {dependencies {classpath 'com.google.gms:google-services:4.3.15'}}
app/build.gradle
文件中添加下方配置。apply plugin: 'com.google.gms.google-services'
app/proguard-rules.pro
文件中,将 TIMPush 相关类加入不混淆名单。-keep class com.tencent.qcloud.** { *; }-keep class com.tencent.timpush.** { *; }
app/build.gradle
文件中,将应用包名修改为您的实际应用包名。applicationId 'com.****.callkit'
application
类中,监听 TIMPush 发出的事件通知,实现自动登录。import com.tencent.qcloud.tuicore.TUIConstants import com.tencent.qcloud.tuicore.TUICore import com.tencent.qcloud.tuicore.interfaces.ITUINotification class BaseApplication : Application() { override fun onCreate() { super.onCreate() TUICore.registerEvent(TUIConstants.TIMPush.EVENT_IM_LOGIN_AFTER_APP_WAKEUP_KEY, TUIConstants.TIMPush.EVENT_IM_LOGIN_AFTER_APP_WAKEUP_SUB_KEY) { key, subKey, param ->if (TUIConstants.TIMPush.EVENT_IM_LOGIN_AFTER_APP_WAKEUP_KEY == key&& TUIConstants.TIMPush.EVENT_IM_LOGIN_AFTER_APP_WAKEUP_SUB_KEY == subKey) { //you need to login again to launch call activity, please implement this method by yourself autoLogin() } } } }
import com.tencent.qcloud.tuicore.TUIConstants; import com.tencent.qcloud.tuicore.TUICore; import com.tencent.qcloud.tuicore.interfaces.ITUINotification;public class BaseApplication extends Application {@Overridepublic void onCreate() {super.onCreate();TUICore.registerEvent(TUIConstants.TIMPush.EVENT_IM_LOGIN_AFTER_APP_WAKEUP_KEY,TUIConstants.TIMPush.EVENT_IM_LOGIN_AFTER_APP_WAKEUP_SUB_KEY, new ITUINotification() {@Overridepublic void onNotifyEvent(String key, String subKey, Map<String, Object> param) {if (TUIConstants.TIMPush.EVENT_IM_LOGIN_AFTER_APP_WAKEUP_KEY.equals(key)&& TUIConstants.TIMPush.EVENT_IM_LOGIN_AFTER_APP_WAKEUP_SUB_KEY.equals(subKey)) {//you need to login again to launch call activity, please implement this method by yourselfautoLogin();}}});}}
tuicallkit-kt/src/main/res/raw/phone_ringing.mp3
文件。fun requestPermission(context: Context?) {//In TUICallKit,Please open both OverlayWindows and Background pop-ups permission.PermissionRequester.newInstance(PermissionRequester.FLOAT_PERMISSION, PermissionRequester.BG_START_PERMISSION).request()}
手机 > 系统设置 > 应用管理 > 应用
中手动开启上述权限。Pixel 4a | VIVO |
| |
info_rtc@tencent.com
。
本页内容是否解决了您的问题?