Kaynağa Gözat

修改机构端推送数据解析

Pq 1 yıl önce
ebeveyn
işleme
2cd9b1959e

+ 1 - 1
student/src/main/java/com/cooleshow/student/helper/PushIntentParseHelper.java → BaseLibrary/src/main/java/com/cooleshow/base/utils/helper/PushIntentParseHelper.java

@@ -1,4 +1,4 @@
-package com.cooleshow.student.helper;
+package com.cooleshow.base.utils.helper;
 
 import android.content.Intent;
 import android.net.Uri;

+ 17 - 16
institution/src/main/java/com/cooleshow/institution/stu/ui/main/MainActivity.java

@@ -23,6 +23,7 @@ import com.cooleshow.base.utils.JumpUtils;
 import com.cooleshow.base.utils.LogUtils;
 import com.cooleshow.base.utils.ToastUtil;
 import com.cooleshow.base.utils.helper.MidiFileHelper;
+import com.cooleshow.base.utils.helper.PushIntentParseHelper;
 import com.cooleshow.base.utils.helper.QMUIStatusBarHelper;
 import com.cooleshow.base.utils.helper.UpdateAppHelper;
 import com.cooleshow.chatmodule.contract.IUnReadMessageObserver;
@@ -131,22 +132,22 @@ public class MainActivity extends BaseMVPActivity<ActivityInstitutionMainLayoutB
             }
             return;
         }
-//        String intentResult = PushIntentParseHelper.getIntentMemoFrom(intent);
-//        LogUtils.i("pq", "intentResult:" + intentResult);
-//        if (!TextUtils.isEmpty(intentResult)) {
-//            if (TextUtils.equals(intentResult, PushIntentParseHelper.RONG_PUSH_ACTION_TAG)) {
-//                //融云推送相关
-//                //选中聊天
-//                setPositionItem(2);
-//                return;
-//            }
-//            try {
-//                RouteBean routeBean = GsonUtils.fromJson(intentResult, RouteBean.class);
-//                JumpUtils.jump(routeBean);
-//            } catch (Exception e) {
-//                e.printStackTrace();
-//            }
-//        }
+        String intentResult = PushIntentParseHelper.getIntentMemoFrom(intent);
+        LogUtils.i("pq", "intentResult:" + intentResult);
+        if (!TextUtils.isEmpty(intentResult)) {
+            if (TextUtils.equals(intentResult, PushIntentParseHelper.RONG_PUSH_ACTION_TAG)) {
+                //融云推送相关
+                //选中聊天
+                setPositionItem(2);
+                return;
+            }
+            try {
+                RouteBean routeBean = GsonUtils.fromJson(intentResult, RouteBean.class);
+                JumpUtils.jump(routeBean);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
     }
 
     private void setStyleConfig() {

+ 1 - 1
student/src/main/java/com/cooleshow/student/ui/main/MainActivity.java

@@ -35,6 +35,7 @@ import com.cooleshow.base.utils.LogUtils;
 import com.cooleshow.base.utils.ToastUtil;
 import com.cooleshow.base.utils.UiUtils;
 import com.cooleshow.base.utils.helper.MidiFileHelper;
+import com.cooleshow.base.utils.helper.PushIntentParseHelper;
 import com.cooleshow.base.utils.helper.QMUIStatusBarHelper;
 import com.cooleshow.base.utils.helper.UpdateAppHelper;
 import com.cooleshow.base.utils.helper.WebStartHelper;
@@ -50,7 +51,6 @@ import com.cooleshow.student.constants.CommonConfig;
 import com.cooleshow.student.contract.MainContract;
 import com.cooleshow.student.databinding.ActivityMainBinding;
 import com.cooleshow.student.helper.EventHelper;
-import com.cooleshow.student.helper.PushIntentParseHelper;
 import com.cooleshow.student.presenter.main.MainPresenter;
 import com.cooleshow.usercenter.bean.StudentUserInfo;
 import com.cooleshow.usercenter.bean.UserInfo;

+ 0 - 83
teacher/src/main/java/com/cooleshow/teacher/helper/PushIntentParseHelper.java

@@ -1,83 +0,0 @@
-package com.cooleshow.teacher.helper;
-
-import android.content.Intent;
-import android.net.Uri;
-import android.text.TextUtils;
-import android.util.Log;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-
-/**
- * Author by pq, Date on 2022/5/27.
- */
-public class PushIntentParseHelper {
-
-    public static final String RONG_PUSH_SCHEME = "rong";//融云推送scheme
-    public static final String RONG_PUSH_ACTION_TAG = "rongIM";//融云推送action
-
-
-    /**
-     * 处理点击事件,当前启动配置的Activity都是使用
-     * Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK
-     * 方式启动,只需要在onCreat中调用此方法进行处理
-     */
-
-    /**
-     * 通知附加字段
-     **/
-    private static final String KEY_EXTRAS = "n_extras";
-
-    private static String parsePushIntent(Intent intent) {
-        String data = null;
-
-        //获取华为平台附带的jpush信息
-        if (intent.getData() != null) {
-            data = intent.getData().toString();
-        }
-        //获取fcm/oppo/小米/vivo/魅族 平台附带的jpush信息
-        if (TextUtils.isEmpty(data) && intent.getExtras() != null) {
-            data = intent.getExtras().getString("JMessageExtra");
-        }
-        Log.i("pq", "msg content is " + String.valueOf(data));
-        return data;
-    }
-
-    private static String getMemoFromPushIntent(String intent) {
-        JSONObject jsonObject = null;
-        try {
-            jsonObject = new JSONObject(intent);
-            JSONObject n_extras = (JSONObject) jsonObject.opt(KEY_EXTRAS);
-            if (n_extras != null) {
-                return n_extras.optString("memo");
-            }
-        } catch (JSONException e) {
-            e.printStackTrace();
-        }
-        return "";
-    }
-
-
-    public static String getIntentMemoFrom(Intent intent) {
-        String memo = "";
-        Uri data = intent.getData();
-        if (data != null && data.isHierarchical()) {
-            //判断是否是融云推送
-            if (TextUtils.equals(RONG_PUSH_SCHEME, data.getScheme())) {
-                memo = RONG_PUSH_ACTION_TAG;
-            }
-        }
-        if (TextUtils.isEmpty(memo)) {
-            //判断是否是极光推送
-            String result = parsePushIntent(intent);
-            if (!TextUtils.isEmpty(result)) {
-                memo = getMemoFromPushIntent(result);
-            }
-        }
-
-        if (TextUtils.isEmpty(memo)) {
-            memo = intent.getStringExtra("memo");
-        }
-        return memo;
-    }
-}

+ 1 - 1
teacher/src/main/java/com/cooleshow/teacher/ui/main/MainActivity.java

@@ -29,6 +29,7 @@ import com.cooleshow.base.utils.LogUtils;
 import com.cooleshow.base.utils.ToastUtil;
 import com.cooleshow.base.utils.UiUtils;
 import com.cooleshow.base.utils.helper.MidiFileHelper;
+import com.cooleshow.base.utils.helper.PushIntentParseHelper;
 import com.cooleshow.base.utils.helper.QMUIStatusBarHelper;
 import com.cooleshow.base.utils.helper.UpdateAppHelper;
 import com.cooleshow.base.utils.helper.WebStartHelper;
@@ -42,7 +43,6 @@ import com.cooleshow.teacher.adapter.HomePageAdapter;
 import com.cooleshow.teacher.bean.TeacherPromoteIncomeBean;
 import com.cooleshow.teacher.contract.MainContract;
 import com.cooleshow.teacher.databinding.ActivityMainBinding;
-import com.cooleshow.teacher.helper.PushIntentParseHelper;
 import com.cooleshow.teacher.presenter.main.MainPresenter;
 import com.cooleshow.usercenter.bean.TeacherUserInfo;
 import com.cooleshow.usercenter.bean.UserInfo;