From c303ad1f833c512afc8c84d4d5fb229f151c291f Mon Sep 17 00:00:00 2001 From: 18142669586 <1669783059@qq.com> Date: Mon, 22 Aug 2022 18:15:47 +0800 Subject: [PATCH] 111 --- .../imrongcloud/RongcloudIMManager.java | 5 ++- .../yunbao/main/activity/MainActivity.java | 33 +++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/com/yunbao/common/manager/imrongcloud/RongcloudIMManager.java b/common/src/main/java/com/yunbao/common/manager/imrongcloud/RongcloudIMManager.java index 76e329187..bf70d3ca4 100644 --- a/common/src/main/java/com/yunbao/common/manager/imrongcloud/RongcloudIMManager.java +++ b/common/src/main/java/com/yunbao/common/manager/imrongcloud/RongcloudIMManager.java @@ -32,7 +32,10 @@ import static com.yunbao.common.CommonAppContext.isReady; */ public class RongcloudIMManager { //融云开发者平台注册app唯一识别符 - public static final String RONG_IM_KEY = "uwd1c0sxu1p71"; +// public static final String RONG_IM_KEY = "uwd1c0sxu1p71"; + //测试环境 + public static final String RONG_IM_KEY = "pvxdm17jpd3hr"; + private static final String CLASSNAME = "RongcloudIMManager"; /** diff --git a/main/src/main/java/com/yunbao/main/activity/MainActivity.java b/main/src/main/java/com/yunbao/main/activity/MainActivity.java index 8e397bc6c..aa3a7ae0d 100644 --- a/main/src/main/java/com/yunbao/main/activity/MainActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MainActivity.java @@ -6,6 +6,8 @@ import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.annotation.SuppressLint; import android.app.Dialog; +import android.app.NotificationChannel; +import android.app.PendingIntent; import android.content.ClipData; import android.content.Context; import android.content.Intent; @@ -125,11 +127,18 @@ import cn.rongcloud.rtc.api.RCRTCConfig; import cn.rongcloud.rtc.api.RCRTCEngine; import io.reactivex.Observer; import io.reactivex.disposables.Disposable; +import io.rong.imkit.config.RongConfigCenter; +import io.rong.imkit.notification.NotificationConfig; import io.rong.imlib.RongIMClient; import kotlin.Unit; import static com.yunbao.common.CommonAppContext.isReady; +import io.rong.imlib.model.Message; +import io.rong.push.PushManager; +import io.rong.push.PushType; +import kotlin.*; + @Route(path = RouteUtil.PATH_MAIN) public class MainActivity extends AbsActivity implements MainAppBarLayoutListener { @@ -292,6 +301,8 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene // Log and toast Log.d(TAG, token); + PushManager.getInstance() + .onReceiveToken(MainActivity.this, PushType.GOOGLE_FCM, token); Toast.makeText(MainActivity.this, token, Toast.LENGTH_SHORT).show(); } }); @@ -392,6 +403,28 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene mViewPager.setCurrentItem(0); mTabButtonGroup.setCurPosition(0); isInstructor(); + + RongConfigCenter.notificationConfig().setInterceptor(new NotificationConfig.Interceptor() { + @Override + public boolean isNotificationIntercepted(Message message) { + return true; + } + + @Override + public PendingIntent onPendingIntent(PendingIntent pendingIntent, Intent intent) { + return null; + } + + @Override + public boolean isHighPriorityMessage(Message message) { + return false; + } + + @Override + public NotificationChannel onRegisterChannel(NotificationChannel notificationChannel) { + return null; + } + }); RxView.clicks(findViewById(R.id.banner_click)) .throttleFirst(2, TimeUnit.SECONDS) .subscribe(new Observer() {