From fff1f19a381e6ad295cb3e7bd41cce48e74fbeea Mon Sep 17 00:00:00 2001
From: client_Hale <339726288@qq.com>
Date: 星期二, 04 九月 2018 11:45:30 +0800
Subject: [PATCH] update 猫耳SDK加入; 渠道差异逻辑细化

---
 Project/app/src/main/java/com/secondworld/univeralsdk/JPushReceiver.java |   37 +++++++++++++++++++------------------
 1 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/Project/app/src/main/java/com/secondworld/univeralsdk/JPushReceiver.java b/Project/app/src/main/java/com/secondworld/univeralsdk/JPushReceiver.java
index 65ddd06..c0401d9 100644
--- a/Project/app/src/main/java/com/secondworld/univeralsdk/JPushReceiver.java
+++ b/Project/app/src/main/java/com/secondworld/univeralsdk/JPushReceiver.java
@@ -4,10 +4,10 @@
 import android.content.Context;
 import android.content.Intent;
 import android.os.Bundle;
+import android.support.v4.content.LocalBroadcastManager;
 import android.util.Log;
 
-import com.unity3d.player.UnityPlayer;
-
+import org.json.JSONException;
 import org.json.JSONObject;
 
 import java.util.HashMap;
@@ -37,16 +37,13 @@
                 String regId = bundle.getString(JPushInterface.EXTRA_REGISTRATION_ID);
                 Log.d(TAG, "[MyReceiver] 鎺ユ敹Registration Id : " + regId);
                 //send the Registration Id to your server...
-                Map<String, Object> _msg = new HashMap<>();
-                _msg.put("code", 2004);
-                _msg.put("clientID", regId);
-                JSONObject _json = new JSONObject(_msg);
-                UnityPlayer.UnitySendMessage("SDKUtility", "Recv_SDK_Callback", _json.toString());
+                Map<String, Object> _msgStruct = new HashMap<>();
+                _msgStruct.put("code", CodeA2U.PushClientID);
+                _msgStruct.put("clientID", regId);
+                UniversalUtil.sendMessageToUnity(_msgStruct);
             }
             else if (JPushInterface.ACTION_MESSAGE_RECEIVED.equals(intent.getAction()))
             {
-                Log.d(TAG, "[MyReceiver] 鎺ユ敹鍒版帹閫佷笅鏉ョ殑鑷畾涔夋秷鎭�: " + bundle.getString(
-                        JPushInterface.EXTRA_MESSAGE));
                 processCustomMessage(context, bundle);
             }
             else if (JPushInterface.ACTION_NOTIFICATION_RECEIVED.equals(intent.getAction()))
@@ -57,14 +54,12 @@
             }
             else if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction()))
             {
-//                Log.d(TAG, "[MyReceiver] 鐢ㄦ埛鐐瑰嚮鎵撳紑浜嗛�氱煡");
-//                //鎵撳紑鑷畾涔夌殑Activity
-//                Intent i = new Intent(context, TestActivity.class);
-//                i.putExtras(bundle);
-//                //i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-//                i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP );
-//                context.startActivity(i);
-
+                Log.d(TAG, "[MyReceiver] 鐢ㄦ埛鐐瑰嚮鎵撳紑浜嗛�氱煡");
+                //鎵撳紑鑷畾涔夌殑Activity
+                Intent i = new Intent(context, MainActivity.class);
+                i.putExtras(bundle);
+                i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
+                context.startActivity(i);
             }
             else if (JPushInterface.ACTION_RICHPUSH_CALLBACK.equals(intent.getAction()))
             {
@@ -125,15 +120,21 @@
         return sb.toString();
     }
 
+//    public static final String KEY_TITLE = "title";
+//    public static final String KEY_MESSAGE = "message";
+//    public static final String KEY_EXTRAS = "extras";
+
     //send msg to MainActivity
     private void processCustomMessage(Context context, Bundle bundle)
     {
+        Log.d(TAG, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!![MyReceiver] 鎺ユ敹鍒版帹閫佷笅鏉ョ殑鑷畾涔夋秷鎭�: " + bundle.getString(
+                JPushInterface.EXTRA_MESSAGE));
 //        if (MainActivity.isForeground) {
 //            String message = bundle.getString(JPushInterface.EXTRA_MESSAGE);
 //            String extras = bundle.getString(JPushInterface.EXTRA_EXTRA);
 //            Intent msgIntent = new Intent(MainActivity.MESSAGE_RECEIVED_ACTION);
 //            msgIntent.putExtra(MainActivity.KEY_MESSAGE, message);
-//            if (!ExampleUtil.isEmpty(extras)) {
+//            if (!UniversalUtil.isEmpty(extras)) {
 //                try {
 //                    JSONObject extraJson = new JSONObject(extras);
 //                    if (extraJson.length() > 0) {

--
Gitblit v1.8.0