From 071085275e07d96eda7f970f158482f0d9a8d4bf Mon Sep 17 00:00:00 2001
From: Tong <1025782220@qq.com>
Date: 星期三, 01 九月 2021 13:33:32 +0800
Subject: [PATCH] 极光库整合完成

---
 HDL-ON_Android/Other/JPush/JPushReceiver.cs |  103 +++++++++++++++++++++++++++++++--------------------
 1 files changed, 63 insertions(+), 40 deletions(-)

diff --git a/HDL-ON_Android/Other/JPush/JPushReceiver.cs b/HDL-ON_Android/Other/JPush/JPushReceiver.cs
index 063eb47..5f56fd3 100644
--- a/HDL-ON_Android/Other/JPush/JPushReceiver.cs
+++ b/HDL-ON_Android/Other/JPush/JPushReceiver.cs
@@ -7,22 +7,25 @@
 using HDL_ON;
 using HDL_ON.DAL.Server;
 using Shared;
+using Android.OS;
 
 namespace HDL_ON_Android
-{
-    
+{
+
     [BroadcastReceiver(Enabled = true, Exported = false)]
     [Android.App.IntentFilter(new string[]
     {
         "cn.jpush.android.intent.RECEIVE_MESSAGE"
     },
-    Categories=new string[] 
+    Categories = new string[]
     {
         "com.hdl.onpro"
     })]
     public class JPushReceiver : JPushMessageReceiver
-    {
-
+    {
+        private static Handler UiHandler = new Handler(Looper.MainLooper);
+
+
         private static string TAG = "JPushReceiver";
         /// <summary>
         /// 鐢ㄦ埛鐐瑰嚮鎵撳紑浜嗛�氱煡
@@ -66,20 +69,21 @@
             Utlis.WriteLine("PushMes title : " + pushMes.Title);
             Utlis.WriteLine("PushMes message : " + pushMes.Content);
             Utlis.WriteLine("PushMes extras : " + pushMes.Extras);
-            Utlis.WriteLine("PushMes HomeId : " + pushMes.HomeId);
+            Utlis.WriteLine("PushMes HomeId : " + pushMes.HomeId);
+
             Shared.Application.RunOnMainThread(() =>
             {
                 HDLCommon.Current.AdjustPushMessage(pushMes);
             });
 
-        }
-
+        }
+
         /// <summary>
         /// 
         /// </summary>
         /// <param name="pushMes"></param>
         /// <returns></returns>
-        ExpandData GetJPushExpandData(JPushMessageInfo pushMes)
+        static ExpandData GetJPushExpandData(JPushMessageInfo pushMes)
         {
             try
             {
@@ -149,8 +153,9 @@
         /// </summary>
         /// <param name="context"></param>
         /// <param name="notificationMessage"></param>
-        private void OpenNotification(Context context, NotificationMessage notificationMessage)
-        {
+        public static void OpenNotification(Context context, NotificationMessage notificationMessage)
+        {
+
             try
             {
                 var pushMes = new JPushMessageInfo()
@@ -172,33 +177,32 @@
                 Utlis.WriteLine("PushMes title : " + pushMes.Title);
                 Utlis.WriteLine("PushMes message : " + pushMes.Content);
                 Utlis.WriteLine("PushMes extras : " + pushMes.Extras);
-                Utlis.WriteLine("PushMes HomeId : " + pushMes.HomeId);
-                Shared.Application.RunOnMainThread(() =>
-                {
-                    Intent i = new Intent(context, typeof(BaseActivity));//Intent intent=new Intent( 璧峰缁勪欢瀵硅薄 , 鐩爣 Service.class);
-                    i.SetFlags(ActivityFlags.NewTask);
-                    context.StartActivity(i);
-
-                    HDLCommon.Current.AdjustPushMessage(pushMes);
-                });
-
-                //Shared.Application.RunOnMainThread(() =>
-                //{
-                //    if (Shared.Application.Activity == null)
-                //    {
-                //        var tempIntent = new Intent(context, typeof(Shared.BaseActivity));//Intent intent=new Intent( 璧峰缁勪欢瀵硅薄 , 鐩爣 Service.class);
-                //        tempIntent.SetFlags(ActivityFlags.BroughtToFront);
-                //        context.StartActivity(tempIntent);
-
-                //        HDLCommon.Current.AdjustPushMessage(pushMes);
-                //    }
-                //    else
-                //    {
-
-                //        (Shared.Application.Activity as BaseActivity).MoveToFront();
-                //        HDLCommon.Current.AdjustPushMessage(pushMes);
-                //    }
-                //});
+                Utlis.WriteLine("PushMes HomeId : " + pushMes.HomeId);
+
+
+                Intent i = new Intent(context, typeof(BaseActivity));//Intent intent=new Intent( 璧峰缁勪欢瀵硅薄 , 鐩爣 Service.class);
+                i.SetFlags(ActivityFlags.NewTask);
+                context.StartActivity(i);
+                //瑙f瀽msg
+                AdjustPushMessage(pushMes);
+
+                //Shared.Application.RunOnMainThread(() =>
+                //{
+                //    if (Shared.Application.Activity == null)
+                //    {
+                //        var tempIntent = new Intent(context, typeof(Shared.BaseActivity));//Intent intent=new Intent( 璧峰缁勪欢瀵硅薄 , 鐩爣 Service.class);
+                //        tempIntent.SetFlags(ActivityFlags.BroughtToFront);
+                //        context.StartActivity(tempIntent);
+
+                //        HDLCommon.Current.AdjustPushMessage(pushMes);
+                //    }
+                //    else
+                //    {
+
+                //        (Shared.Application.Activity as BaseActivity).MoveToFront();
+                //        HDLCommon.Current.AdjustPushMessage(pushMes);
+                //    }
+                //});
             }
             catch
             {
@@ -209,6 +213,25 @@
             //    Utlis.WriteLine(ex.ToString());
             //}
         }
-    }
-    
+
+
+
+        public static void AdjustPushMessage(JPushMessageInfo pushMes)
+        {
+
+            new System.Threading.Thread(new System.Threading.ThreadStart(() =>
+            {
+                while (MainPage.BasePageView == null)
+                {
+                    System.Threading.Thread.Sleep(300);
+                }
+                Shared.Application.RunOnMainThread(() =>
+                {
+                    HDLCommon.Current.AdjustPushMessage(pushMes);
+                });
+            })).Start();
+
+        }
+    }
+
 }
\ No newline at end of file

--
Gitblit v1.8.0