From 6ae9f81d545f44a85c34dea1c11df8b70e3f940f Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期三, 09 四月 2025 10:29:29 +0800
Subject: [PATCH] 2025-04-09 10:29:16 1.1.0

---
 app/src/main/java/com/hdl/photovoltaic/jpush/JPushReceiverService.java |   89 ++++++++++++++++++++++++++++++--------------
 1 files changed, 60 insertions(+), 29 deletions(-)

diff --git a/app/src/main/java/com/hdl/photovoltaic/jpush/JPushReceiverService.java b/app/src/main/java/com/hdl/photovoltaic/jpush/JPushReceiverService.java
index 51b23ab..aa577c5 100644
--- a/app/src/main/java/com/hdl/photovoltaic/jpush/JPushReceiverService.java
+++ b/app/src/main/java/com/hdl/photovoltaic/jpush/JPushReceiverService.java
@@ -1,21 +1,17 @@
 package com.hdl.photovoltaic.jpush;
 
 import android.content.Context;
-import android.content.Intent;
-import android.os.Bundle;
+import android.text.TextUtils;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.google.gson.Gson;
-import com.hdl.photovoltaic.config.ConstantManage;
+import com.hdl.photovoltaic.other.HdlJpushLogic;
 import com.hdl.photovoltaic.other.HdlLogLogic;
-import com.hdl.photovoltaic.ui.MyPowerStationActivity;
-import com.hdl.photovoltaic.ui.StartActivity;
-import com.hdl.photovoltaic.ui.bean.BUserInfo;
-import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus;
 
-import org.greenrobot.eventbus.EventBus;
+import java.util.Objects;
 
 import cn.jpush.android.api.CustomMessage;
-import cn.jpush.android.api.JPushInterface;
 import cn.jpush.android.api.NotificationMessage;
 import cn.jpush.android.service.JPushMessageService;
 
@@ -23,6 +19,7 @@
  * 鎺ユ敹鏋佸厜鎺ㄩ�佹秷鎭�
  */
 public class JPushReceiverService extends JPushMessageService {
+
 
     /**
      * 鑷畾涔夋秷鎭洖璋�
@@ -32,7 +29,7 @@
      */
     public void onMessage(Context context, CustomMessage customMessage) {
 
-        HdlLogLogic.print("鏋佸厜--->鑷畾涔夋秷鎭洖璋�--->" + new Gson().toJson(customMessage), true);
+        HdlLogLogic.print("鏋佸厜---鑷畾涔夋秷鎭洖璋�---" + new Gson().toJson(customMessage), false);
     }
 
     /**
@@ -42,23 +39,10 @@
      * @param message 鎺ユ敹鍒扮殑閫氱煡鍐呭
      */
     public void onNotifyMessageOpened(Context context, NotificationMessage message) {
-
+        JPushMessageInfoBean jPushMessageInfoBean = pushDataProcessing(message);
+        HdlJpushLogic.getInstance().JpushPushCommonData(context, jPushMessageInfoBean, true);
 //        //鐐瑰嚮鍚庡垹闄ゆ湰鍦伴�氱煡
 //        JPushInterface.clearAllNotifications(context);
-        HdlLogLogic.print("鏋佸厜--->鐐瑰嚮閫氱煡鍥炶皟--->" + new Gson().toJson(message), true);
-        Intent intent = new Intent(context, MyPowerStationActivity.class);
-//        Bundle bundle = new Bundle();
-//        bundle.putString(JPushInterface.EXTRA_NOTIFICATION_TITLE, message.notificationTitle);
-//        bundle.putString(JPushInterface.EXTRA_ALERT, message.notificationContent);
-//        intent.putExtras(bundle);
-        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
-        intent.putExtra("skip", "skip");//鏍囪瘑璺宠浆
-        context.startActivity(intent);
-
-        BaseEventBus bus = new BaseEventBus();
-        bus.setTopic(ConstantManage.message_function_push_post);
-        EventBus.getDefault().postSticky(bus);
-
     }
 
     /**
@@ -68,8 +52,8 @@
      * @param message 鎺ユ敹鍒扮殑閫氱煡鍐呭
      */
     public void onNotifyMessageArrived(Context context, NotificationMessage message) {
-        HdlLogLogic.print("鏋佸厜--->鎺ユ敹鍒扮殑閫氱煡鍐呭--->" + new Gson().toJson(message), true);
-
+        JPushMessageInfoBean jPushMessageInfoBean = pushDataProcessing(message);
+        HdlJpushLogic.getInstance().JpushPushCommonData(context, jPushMessageInfoBean, false);
     }
 
     /**
@@ -79,7 +63,7 @@
      * @param registrationId 娉ㄥ唽 id
      */
     public void onRegister(Context context, String registrationId) {
-        HdlLogLogic.print("鏋佸厜--->娉ㄥ唽鎴愬姛鍥炶皟Id--->" + registrationId, true);
+        HdlLogLogic.print("鏋佸厜---娉ㄥ唽鎴愬姛鍥炶皟Id:" + registrationId, false);
     }
 
     /**
@@ -89,7 +73,54 @@
      * @param isConnected 闀胯繛鎺ョ姸鎬�
      */
     public void onConnected(Context context, boolean isConnected) {
-        HdlLogLogic.print("鏋佸厜--->闀胯繛鎺ョ姸鎬佸洖璋�--->" + isConnected, true);
+        HdlLogLogic.print("鏋佸厜---闀胯繛鎺ョ姸鎬佸洖璋�:" + isConnected, false);
+    }
+
+    /**
+     * 鎺ㄩ�佹暟鎹綔澶勭悊
+     */
+    private JPushMessageInfoBean pushDataProcessing(NotificationMessage message) {
+        try {
+            JPushMessageInfoBean jPushMessageInfoBean = new JPushMessageInfoBean();
+            String title = message.notificationTitle;
+            String content = message.notificationContent;
+            String pushData = message.notificationExtras;
+            jPushMessageInfoBean.setTitle(title);
+            jPushMessageInfoBean.setContent(content);
+            if (TextUtils.isEmpty(pushData)) {
+                return jPushMessageInfoBean;
+            }
+            JSONObject expandDataObject = JSON.parseObject(pushData);
+            if (expandDataObject.containsKey("expandData")) {
+                String expandDataJson = Objects.requireNonNull(expandDataObject.get("expandData")).toString();
+                if (TextUtils.isEmpty(expandDataJson)) {
+                    return jPushMessageInfoBean;
+                }
+                jPushMessageInfoBean.setExpandData(expandDataJson);
+                JSONObject expantContentObject = JSON.parseObject(expandDataJson);
+                if (expantContentObject.containsKey("messageType")) {
+                    String messageType = Objects.requireNonNull(expantContentObject.get("messageType")).toString();
+                    if (!TextUtils.isEmpty(messageType)) {
+                        jPushMessageInfoBean.setMessageType(messageType);
+                    }
+                }
+                if (expantContentObject.containsKey("homeId")) {
+                    String homeId = Objects.requireNonNull(expantContentObject.get("homeId")).toString();
+                    if (!TextUtils.isEmpty(homeId)) {
+                        jPushMessageInfoBean.setHomeId(homeId);
+                    }
+                }
+                if (expantContentObject.containsKey("expantContent")) {
+                    String expantContentJosn = Objects.requireNonNull(expantContentObject.get("expantContent")).toString();
+                    if (!TextUtils.isEmpty(expantContentJosn)) {
+                        jPushMessageInfoBean.setExpantContent(expantContentJosn);
+                    }
+                }
+            }
+            return jPushMessageInfoBean;
+        } catch (Exception e) {
+            return new JPushMessageInfoBean();
+        }
     }
 
 }

--
Gitblit v1.8.0