Parcourir la source

feat: Push点击跳转到会话

DoggyZhang il y a 1 mois
Parent
commit
0beaa9d578

+ 2 - 0
module/im/src/main/java/com/adealink/weparty/im/IMServiceImpl.kt

@@ -13,6 +13,7 @@ import com.adealink.weparty.im.service.TIMAppService
 import com.adealink.weparty.im.session.mesasge.CustomMessageViewHolder
 import com.adealink.weparty.im.session.mesasge.CustomMessageViewHolder
 import com.adealink.weparty.im.session.mesasge.OfficialImageTextMessageBean
 import com.adealink.weparty.im.session.mesasge.OfficialImageTextMessageBean
 import com.adealink.weparty.im.session.mesasge.PlaymateOrderMessageBean
 import com.adealink.weparty.im.session.mesasge.PlaymateOrderMessageBean
+import com.adealink.weparty.im.util.TUIUtils
 import com.adealink.weparty.module.im.IIMService
 import com.adealink.weparty.module.im.IIMService
 import com.adealink.weparty.module.profile.ProfileModule
 import com.adealink.weparty.module.profile.ProfileModule
 import com.adealink.weparty.module.profile.data.UserInfo
 import com.adealink.weparty.module.profile.data.UserInfo
@@ -61,6 +62,7 @@ class IMServiceImpl : IIMService {
         TIMPushManager.getInstance().addPushListener(object : TIMPushListener() {
         TIMPushManager.getInstance().addPushListener(object : TIMPushListener() {
             override fun onNotificationClicked(ext: String?) {
             override fun onNotificationClicked(ext: String?) {
                 Log.i(TAG_IM_PUSH, "onNotificationClicked:$ext")
                 Log.i(TAG_IM_PUSH, "onNotificationClicked:$ext")
+                TUIUtils.handleOfflinePush(ext)
             }
             }
         })
         })
 
 

+ 35 - 0
module/im/src/main/java/com/adealink/weparty/im/config/InitSetting.java

@@ -5,6 +5,9 @@ import android.content.SharedPreferences;
 
 
 import com.adealink.frame.log.Log;
 import com.adealink.frame.log.Log;
 import com.adealink.weparty.commonui.util.BrandUtil;
 import com.adealink.weparty.commonui.util.BrandUtil;
+import com.adealink.weparty.im.push.OfflinePushAPI;
+import com.adealink.weparty.im.push.OfflinePushConfigs;
+import com.adealink.weparty.im.push.OfflinePushLocalReceiver;
 import com.tencent.imsdk.v2.V2TIMManager;
 import com.tencent.imsdk.v2.V2TIMManager;
 import com.tencent.imsdk.v2.V2TIMValueCallback;
 import com.tencent.imsdk.v2.V2TIMValueCallback;
 import com.tencent.qcloud.tuicore.TUICore;
 import com.tencent.qcloud.tuicore.TUICore;
@@ -22,6 +25,9 @@ public class InitSetting {
     private static final String TAG = InitSetting.class.getSimpleName();
     private static final String TAG = InitSetting.class.getSimpleName();
     public Context mContext;
     public Context mContext;
 
 
+    private OfflinePushAPI offlinePushAPI;
+    private OfflinePushLocalReceiver offlinePushLocalReceiver = null;
+
     public InitSetting(Context context) {
     public InitSetting(Context context) {
         this.mContext = context;
         this.mContext = context;
     }
     }
@@ -36,11 +42,15 @@ public class InitSetting {
         final SharedPreferences sharedPreferences = mContext.getSharedPreferences("TUIKIT_DEMO_SETTINGS", mContext.MODE_PRIVATE);
         final SharedPreferences sharedPreferences = mContext.getSharedPreferences("TUIKIT_DEMO_SETTINGS", mContext.MODE_PRIVATE);
         int callbackMode = sharedPreferences.getInt("test_OfflinePushCallbackMode_v2", 1);
         int callbackMode = sharedPreferences.getInt("test_OfflinePushCallbackMode_v2", 1);
         Log.i(TAG, "initOfflinePushConfigs callbackMode = " + callbackMode);
         Log.i(TAG, "initOfflinePushConfigs callbackMode = " + callbackMode);
+        OfflinePushConfigs.getOfflinePushConfigs().setClickNotificationCallbackMode(callbackMode);
+
         // ring
         // ring
         boolean enablePrivateRing = sharedPreferences.getBoolean("test_enable_private_ring", false);
         boolean enablePrivateRing = sharedPreferences.getBoolean("test_enable_private_ring", false);
         Map<String, Object> param = new HashMap<>();
         Map<String, Object> param = new HashMap<>();
         param.put(TUIChatConstants.OFFLINE_MESSAGE_PRIVATE_RING, enablePrivateRing);
         param.put(TUIChatConstants.OFFLINE_MESSAGE_PRIVATE_RING, enablePrivateRing);
         TUICore.notifyEvent(TUIChatConstants.EVENT_KEY_OFFLINE_MESSAGE_PRIVATE_RING, TUIChatConstants.EVENT_SUB_KEY_OFFLINE_MESSAGE_PRIVATE_RING, param);
         TUICore.notifyEvent(TUIChatConstants.EVENT_KEY_OFFLINE_MESSAGE_PRIVATE_RING, TUIChatConstants.EVENT_SUB_KEY_OFFLINE_MESSAGE_PRIVATE_RING, param);
+        // register callback
+        registerNotify();
     }
     }
 
 
     public void initBeforeLogin(int imsdkAppId) {
     public void initBeforeLogin(int imsdkAppId) {
@@ -48,6 +58,31 @@ public class InitSetting {
         initBuildInformation();
         initBuildInformation();
     }
     }
 
 
+    private void registerNotify() {
+        if (offlinePushAPI == null) {
+            offlinePushAPI = new OfflinePushAPI();
+        }
+
+        int callbackMode = OfflinePushConfigs.getOfflinePushConfigs().getClickNotificationCallbackMode();
+        android.util.Log.d(TAG, "OfflinePush callback mode:" + callbackMode);
+        switch (callbackMode) {
+            case OfflinePushConfigs.CLICK_NOTIFICATION_CALLBACK_NOTIFY:
+                // 1 TUICore NotifyEvent
+                offlinePushAPI.registerNotifyEvent();
+                break;
+            case OfflinePushConfigs.CLICK_NOTIFICATION_CALLBACK_BROADCAST:
+                // 2 broadcast
+                if (offlinePushLocalReceiver == null) {
+                    offlinePushLocalReceiver = new OfflinePushLocalReceiver();
+                }
+                offlinePushAPI.registerNotificationReceiver(mContext, offlinePushLocalReceiver);
+                break;
+            default:
+                // 3 intent
+                break;
+        }
+    }
+
     private void initBuildInformation() {
     private void initBuildInformation() {
         try {
         try {
             JSONObject buildInfoJson = new JSONObject();
             JSONObject buildInfoJson = new JSONObject();

+ 154 - 0
module/im/src/main/java/com/adealink/weparty/im/push/OfflineMessageDispatcher.java

@@ -0,0 +1,154 @@
+package com.adealink.weparty.im.push;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.text.TextUtils;
+
+import com.adealink.frame.log.Log;
+import com.adealink.weparty.commonui.util.BrandUtil;
+import com.google.gson.Gson;
+import com.tencent.qcloud.tuicore.push.OfflinePushExtBusinessInfo;
+import com.tencent.qcloud.tuicore.push.OfflinePushExtInfo;
+
+import java.util.Map;
+import java.util.Set;
+
+public class OfflineMessageDispatcher {
+    private static final String TAG = OfflineMessageDispatcher.class.getSimpleName();
+    private static final String OEMMessageKey = "ext";
+    private static final String XIAOMIMessageKey = "key_message";
+
+    public static OfflinePushExtInfo parseOfflineMessage(Intent intent) {
+        Log.i(TAG, "intent: " + intent);
+        if (intent == null) {
+            return null;
+        }
+
+        Log.i(TAG, "parse OEM push");
+        Bundle bundle = intent.getExtras();
+        Log.i(TAG, "bundle: " + bundle);
+        if (bundle == null) {
+            Log.i(TAG, "bundle is null");
+            return null;
+        } else {
+            String ext = bundle.getString(OEMMessageKey);
+            Log.i(TAG, "push custom data ext: " + ext);
+            if (TextUtils.isEmpty(ext)) {
+                if (BrandUtil.isBrandXiaoMi()) {
+                    ext = getXiaomiMessage(bundle);
+                    return getOfflinePushExtInfo(ext);
+                } else if (BrandUtil.isBrandOppo()) {
+                    ext = getOPPOMessage(bundle);
+                    return getOPPOOfflinePushExtInfo(ext);
+                }
+                Log.i(TAG, "ext is null");
+                return null;
+            } else {
+                return getOfflinePushExtInfo(ext);
+            }
+        }
+    }
+
+    private static String getXiaomiMessage(Bundle bundle) {
+        Map extra = null;
+        try {
+            Object objectMessage = bundle.getSerializable(XIAOMIMessageKey);
+            extra = (Map) objectMessage.getClass().getMethod("getExtra").invoke(objectMessage);
+        } catch (Exception e) {
+            Log.e(TAG, "getXiaomiMessage e = " + e);
+        }
+
+        if (extra == null) {
+            Log.e(TAG, "getXiaomiMessage is null");
+            return "";
+        }
+
+        Log.i(TAG, "getXiaomiMessage ext: " + extra.get("ext").toString());
+        return extra.get("ext").toString();
+    }
+
+    private static String getOPPOMessage(Bundle bundle) {
+        Set<String> set = bundle.keySet();
+        if (set != null) {
+            for (String key : set) {
+                Object value = bundle.get(key);
+                Log.i(TAG, "push custom data key: " + key + " value: " + value);
+                if (TextUtils.equals("entity", key)) {
+                    return value.toString();
+                }
+            }
+        }
+        return null;
+    }
+
+    public static OfflinePushExtInfo getOfflinePushExtInfo(String ext) {
+        if (TextUtils.isEmpty(ext)) {
+            return null;
+        }
+        OfflinePushExtInfo offlinePushExtInfo = null;
+        try {
+            offlinePushExtInfo = new Gson().fromJson(ext, OfflinePushExtInfo.class);
+        } catch (Exception e) {
+            Log.w(TAG, "getOfflinePushExtInfo: " + e.getMessage());
+        }
+        if (offlinePushExtInfo == null) {
+            return null;
+        }
+
+        // getCustomData example
+        /*byte[] byteData = offlinePushExtInfo.getEntity().getCustomData();
+        String customString = "";
+        if (byteData != null && byteData.length > 0) {
+            try {
+                customString = new String(byteData, "UTF-8");
+            } catch (UnsupportedEncodingException e) {
+                Log.w(TAG, "getCustomData e: " + e);
+            }
+        }
+        Log.e(TAG, "customString = " + customString);
+        ChatInfo chatInfo = null;
+        try{
+            chatInfo = new Gson().fromJson(customString, ChatInfo.class);
+        } catch (Exception e) {
+            Log.w(TAG, "getCustomData fromJson e: " + e);
+        }*/
+
+        return OfflinePushExtInfoValidCheck(offlinePushExtInfo);
+    }
+
+    private static OfflinePushExtInfo getOPPOOfflinePushExtInfo(String ext) {
+        if (TextUtils.isEmpty(ext)) {
+            return null;
+        }
+
+        OfflinePushExtInfo offlinePushExtInfo = new OfflinePushExtInfo();
+        OfflinePushExtBusinessInfo bean = null;
+        try {
+            bean = new Gson().fromJson(ext, OfflinePushExtBusinessInfo.class);
+        } catch (Exception e) {
+            Log.w(TAG, "getOPPOOfflinePushExtInfo: " + e.getMessage());
+        }
+
+        if (bean == null) {
+            return null;
+        }
+
+        offlinePushExtInfo.setBusinessInfo(bean);
+        return OfflinePushExtInfoValidCheck(offlinePushExtInfo);
+    }
+
+    private static OfflinePushExtInfo OfflinePushExtInfoValidCheck(OfflinePushExtInfo offlinePushExtInfo) {
+        if (offlinePushExtInfo == null || offlinePushExtInfo.getBusinessInfo() == null) {
+            return null;
+        }
+
+        int version = offlinePushExtInfo.getBusinessInfo().getVersion();
+        int action = offlinePushExtInfo.getBusinessInfo().getChatAction();
+        if (version != 1 || (action != OfflinePushExtInfo.REDIRECT_ACTION_CHAT && action != OfflinePushExtInfo.REDIRECT_ACTION_CALL)) {
+            Log.e(TAG, "unknown version: " + version + " or action: " + action);
+            return null;
+        }
+
+        return offlinePushExtInfo;
+    }
+}

+ 51 - 0
module/im/src/main/java/com/adealink/weparty/im/push/OfflinePushAPI.java

@@ -0,0 +1,51 @@
+package com.adealink.weparty.im.push;
+
+import android.content.Context;
+import android.content.IntentFilter;
+
+import androidx.localbroadcastmanager.content.LocalBroadcastManager;
+
+import com.adealink.frame.log.Log;
+import com.tencent.qcloud.tuicore.TUIConstants;
+import com.tencent.qcloud.tuicore.TUICore;
+import com.tencent.qcloud.tuicore.interfaces.ITUINotification;
+
+import java.util.Map;
+
+public class OfflinePushAPI {
+    public static final String TAG = OfflinePushAPI.class.getSimpleName();
+
+    /**
+     * When the IM console sets the click follow-up action to "use push component callback to jump",After the push is successful, register NotifyEvent through
+     * TUICore, and click the notification bar event will be returned through the TUICore.onNotifyEvent callback.
+     */
+    public void registerNotifyEvent() {
+        TUICore.registerEvent(TUIConstants.TIMPush.EVENT_NOTIFY, TUIConstants.TIMPush.EVENT_NOTIFY_NOTIFICATION, new ITUINotification() {
+            @Override
+            public void onNotifyEvent(String key, String subKey, Map<String, Object> param) {
+                Log.d(TAG, "onNotifyEvent key = " + key + "subKey = " + subKey);
+                if (TUIConstants.TIMPush.EVENT_NOTIFY.equals(key)) {
+                    if (TUIConstants.TIMPush.EVENT_NOTIFY_NOTIFICATION.equals(subKey)) {
+                        if (param != null) {
+                            String extString = (String) param.get(TUIConstants.TIMPush.NOTIFICATION_EXT_KEY);
+//                            TUIUtils.INSTANCE.handleOfflinePush(extString);
+                        }
+                    }
+                }
+            }
+        });
+    }
+
+    /**
+     * When the IM console sets the click follow-up action to "use push component callback to jump",After the push is successful, register the broadcast
+     * receiver, click the notification bar event to return by sending the broadcast callback. IntentFilter 
+     * TUIConstants.TIMPush.NOTIFICATION_BROADCAST_ACTION.
+     */
+    public void registerNotificationReceiver(Context context, OfflinePushLocalReceiver localReceiver) {
+        Log.d(TAG, "registerNotificationReceiver ");
+        IntentFilter intentFilter = new IntentFilter();
+        intentFilter.addAction(TUIConstants.TIMPush.NOTIFICATION_BROADCAST_ACTION);
+        intentFilter.addAction(TUIConstants.TIMPush.BROADCAST_IM_LOGIN_AFTER_APP_WAKEUP);
+        LocalBroadcastManager.getInstance(context).registerReceiver(localReceiver, intentFilter);
+    }
+}

+ 54 - 0
module/im/src/main/java/com/adealink/weparty/im/push/OfflinePushConfigs.java

@@ -0,0 +1,54 @@
+package com.adealink.weparty.im.push;
+
+public class OfflinePushConfigs {
+    private static OfflinePushConfigs offlinePushConfigs;
+
+    public static final int REGISTER_PUSH_MODE_AUTO = 0;
+    public static final int REGISTER_PUSH_MODE_API = 1;
+
+    public static final int CLICK_NOTIFICATION_CALLBACK_INTENT = 0;
+    public static final int CLICK_NOTIFICATION_CALLBACK_NOTIFY = 1;
+    public static final int CLICK_NOTIFICATION_CALLBACK_BROADCAST = 2;
+
+    private int registerPushMode = 0;
+    private int clickNotificationCallbackMode = 0;
+
+    public static OfflinePushConfigs getOfflinePushConfigs() {
+        if (offlinePushConfigs == null) {
+            offlinePushConfigs = new OfflinePushConfigs();
+        }
+        return offlinePushConfigs;
+    }
+
+    /*
+     * Demo integrates two push registration methods to obtain the push service registration method that the application is using:
+     *
+     * REGISTER_PUSH_MODE_AUTO,After the component monitors the account login successfully, to register the push service automatically, you need to manually
+     * configure the push parameters to the PrivateConstants of the push component; REGISTER_PUSH_MODE_API,Manual registration of offline push service, called
+     * when the IM account is successfully logged in, see the interface description for push parameters;
+     */
+    public int getRegisterPushMode() {
+        return registerPushMode;
+    }
+
+    public void setRegisterPushMode(int registerPushMode) {
+        this.registerPushMode = registerPushMode;
+    }
+
+    /*
+     * Demo integrates three ways to click the notification bar to jump to the interface to get the jumping method the application is using:
+     *
+     * CLICK_NOTIFICATION_CALLBACK_INTENT,Configure the jump parameters in the IM console according to the specifications, click the notification bar to jump
+     * to the configuration interface, parse the transparent transmission parameters and perform interface redirection; CLICK_NOTIFICATION_CALLBACK_NOTIFY,In
+     * the IM console configuration jump parameter, select "Use push component callback to jump", and click the notification bar event registration callback to
+     * receive; CLICK_NOTIFICATION_CALLBACK_BROADCAST,In the IM console configuration jump parameter, select "Use push component callback to jump", and click
+     * the notification bar event to register to receive the broadcast;
+     */
+    public int getClickNotificationCallbackMode() {
+        return clickNotificationCallbackMode;
+    }
+
+    public void setClickNotificationCallbackMode(int clickNotificationCallbackMode) {
+        this.clickNotificationCallbackMode = clickNotificationCallbackMode;
+    }
+}

+ 46 - 0
module/im/src/main/java/com/adealink/weparty/im/push/OfflinePushLocalReceiver.java

@@ -0,0 +1,46 @@
+package com.adealink.weparty.im.push;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.text.TextUtils;
+
+import com.adealink.frame.log.Log;
+import com.adealink.weparty.im.util.TUIUtils;
+import com.tencent.qcloud.tuicore.TUIConstants;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class OfflinePushLocalReceiver extends BroadcastReceiver {
+    public static final String TAG = OfflinePushLocalReceiver.class.getSimpleName();
+
+    @Override
+    public void onReceive(Context context, Intent intent) {
+        Log.d(TAG, "BROADCAST_PUSH_RECEIVER intent = " + intent);
+        if (intent != null) {
+            String action = intent.getAction();
+            if (TextUtils.equals(TUIConstants.TIMPush.NOTIFICATION_BROADCAST_ACTION, action)) {
+                String ext = intent.getStringExtra(TUIConstants.TIMPush.NOTIFICATION_EXT_KEY);
+                TUIUtils.INSTANCE.handleOfflinePush(ext);
+            } else if (TextUtils.equals(TUIConstants.TIMPush.BROADCAST_IM_LOGIN_AFTER_APP_WAKEUP, action)) {
+                Bundle receivedBundle = intent.getExtras();
+                if (receivedBundle != null) {
+                    Map<String, String> receivedMap = new HashMap<>();
+                    for (String key : receivedBundle.keySet()) {
+                        String value = receivedBundle.getString(key);
+                        receivedMap.put(key, value);
+                        Log.d(TAG, "key = " + key + ", value = " + value);
+                    }
+                    
+
+                } else {
+                    Log.e(TAG, "receivedBundle is null");
+                }
+            }
+        } else {
+            Log.e(TAG, "onReceive intent is null");
+        }
+    }
+}

+ 109 - 0
module/im/src/main/java/com/adealink/weparty/im/util/TUIUtils.kt

@@ -1,11 +1,120 @@
 package com.adealink.weparty.im.util
 package com.adealink.weparty.im.util
 
 
+import android.app.NotificationManager
+import android.content.Context
+import android.content.Intent
+import android.net.Uri
+import com.adealink.frame.log.Log
+import com.adealink.frame.router.Router
+import com.adealink.weparty.im.push.OfflineMessageDispatcher
+import com.adealink.weparty.im.service.TIMAppService
+import com.adealink.weparty.module.im.IM
 import com.tencent.qcloud.tuicore.interfaces.TUILoginConfig
 import com.tencent.qcloud.tuicore.interfaces.TUILoginConfig
+import com.tencent.qcloud.tuicore.push.OfflinePushExtInfo
 import com.tencent.qcloud.tuikit.timcommon.BuildConfig
 import com.tencent.qcloud.tuikit.timcommon.BuildConfig
 
 
 object TUIUtils {
 object TUIUtils {
     private val TAG: String = TUIUtils::class.java.getSimpleName()
     private val TAG: String = TUIUtils::class.java.getSimpleName()
 
 
+    fun handleOfflinePush(intent: Intent?) {
+        val context: Context = TIMAppService.getAppContext()
+        //登录状态过期/失效
+//        if (V2TIMManager.getInstance().loginStatus == V2TIMManager.V2TIM_STATUS_LOGOUT) {
+//            if (TUIConfig.getTUIHostType() == TUIConfig.TUI_HOST_TYPE_RTCUBE) {
+//                Log.e(TAG, "rtcube not logined")
+//                val param: MutableMap<String?, Any?> = HashMap<String?, Any?>()
+//                param.put(TUIConstants.TIMAppKit.OFFLINE_PUSH_INTENT_DATA, intent)
+//                TUICore.notifyEvent(
+//                    TUIConstants.TIMAppKit.NOTIFY_RTCUBE_EVENT_KEY,
+//                    TUIConstants.TIMAppKit.NOTIFY_RTCUBE_LOGIN_SUB_KEY,
+//                    param
+//                )
+//                return
+//            }
+//            Log.i(TAG, "handleOfflinePush, logout, goHome")
+//            Router.build(context, AppModule.Main.PATH).apply {
+//                addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK)
+//                putExtra(AppModule.Main.EXTRA_MAIN_TAB, MainTab.MESSAGE.tab)
+//                if (intent != null) {
+//                    putExtras(intent)
+//                }
+//            }.start()
+//            return
+//        }
+
+        val offlinePushExtInfo = OfflineMessageDispatcher.parseOfflineMessage(intent)
+        if (offlinePushExtInfo != null) {
+            val manager =
+                context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager?
+            manager?.cancelAll()
+
+            val senderId = offlinePushExtInfo.businessInfo.senderId
+            if (offlinePushExtInfo.businessInfo.chatAction == OfflinePushExtInfo.REDIRECT_ACTION_CHAT) {
+                if (senderId.isNullOrEmpty()) {
+                    return
+                }
+                Log.i(TAG, "handleOfflinePush, goSession($senderId)")
+                val intent = Intent().apply {
+                    setData(
+                        Uri.parse(Router.getDeepLink(IM.Session.PATH)).buildUpon().apply {
+                            appendQueryParameter(IM.Session.EXTRA_CHAT_ID, senderId)
+                        }.build()
+                    )
+                    addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK)
+                }
+                context.startActivity(intent)
+            }
+        }
+    }
+
+    fun handleOfflinePush(ext: String?) {
+        Log.d(TAG, "handleOfflinePush ext = $ext")
+        val offlinePushExtInfo: OfflinePushExtInfo? =
+            OfflineMessageDispatcher.getOfflinePushExtInfo(ext)
+        if (offlinePushExtInfo == null) {
+            return
+        }
+        val context = TIMAppService.getAppContext()
+        //登录状态过期/失效
+//        if (V2TIMManager.getInstance().loginStatus == V2TIMManager.V2TIM_STATUS_LOGOUT) {
+//            if (TUIConfig.getTUIHostType() == TUIConfig.TUI_HOST_TYPE_RTCUBE) {
+//                TUICore.notifyEvent(
+//                    TUIConstants.TIMAppKit.NOTIFY_RTCUBE_EVENT_KEY,
+//                    TUIConstants.TIMAppKit.NOTIFY_RTCUBE_LOGIN_SUB_KEY,
+//                    null
+//                )
+//                return
+//            }
+//            Log.i(TAG, "handleOfflinePush, logout, goHome")
+//            Router.build(context, AppModule.Main.PATH).apply {
+//                addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK)
+//                putExtra(AppModule.Main.EXTRA_MAIN_TAB, MainTab.MESSAGE.tab)
+//                putExtra(TUIConstants.TIMPush.NOTIFICATION_EXT_KEY, ext)
+//            }.start()
+//            return
+//        }
+
+        val manager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager?
+        manager?.cancelAll()
+
+        val senderId = offlinePushExtInfo.businessInfo.senderId
+        if (offlinePushExtInfo.businessInfo.chatAction == OfflinePushExtInfo.REDIRECT_ACTION_CHAT) {
+            if (senderId.isNullOrEmpty()) {
+                return
+            }
+            Log.i(TAG, "handleOfflinePush, goSession($senderId)")
+            val intent = Intent().apply {
+                setData(
+                    Uri.parse(Router.getDeepLink(IM.Session.PATH)).buildUpon().apply {
+                        appendQueryParameter(IM.Session.EXTRA_CHAT_ID, senderId)
+                    }.build()
+                )
+                addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK)
+            }
+            context.startActivity(intent)
+        }
+    }
+
     fun getLoginConfig(): TUILoginConfig {
     fun getLoginConfig(): TUILoginConfig {
         val config = TUILoginConfig()
         val config = TUILoginConfig()
         if (BuildConfig.DEBUG) {
         if (BuildConfig.DEBUG) {