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/HDL-ON_Android.csproj                 |    8 +
 HDL-ON_Android/Properties/AndroidManifest.xml        |    3 
 HDL_APP_Project.sln                                  |    4 
 HDL-ON_Android/Other/JPush/JPushFirmBroadcast.cs     |   41 +++++++--
 HDL-ON_Android/Other/JPush/JPushOpenClickActivity.cs |   37 ++++-----
 HDL-ON_Android/Other/JPush/JPushReceiver.cs          |  103 +++++++++++++++----------
 6 files changed, 123 insertions(+), 73 deletions(-)

diff --git a/HDL-ON_Android/HDL-ON_Android.csproj b/HDL-ON_Android/HDL-ON_Android.csproj
index a752811..22e975d 100644
--- a/HDL-ON_Android/HDL-ON_Android.csproj
+++ b/HDL-ON_Android/HDL-ON_Android.csproj
@@ -28,7 +28,7 @@
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <DebugSymbols>True</DebugSymbols>
     <DebugType>portable</DebugType>
-    <Optimize>False</Optimize>
+    <Optimize>false</Optimize>
     <OutputPath>bin\Debug\</OutputPath>
     <DefineConstants>DEBUG;TRACE;__Android__</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
@@ -43,6 +43,12 @@
     <AndroidSigningKeyPass>85521566</AndroidSigningKeyPass>
     <AndroidSigningKeyAlias>on_plus</AndroidSigningKeyAlias>
     <PlatformTarget>AnyCPU</PlatformTarget>
+    <AotAssemblies>false</AotAssemblies>
+    <EnableLLVM>false</EnableLLVM>
+    <AndroidEnableProfiledAot>false</AndroidEnableProfiledAot>
+    <BundleAssemblies>false</BundleAssemblies>
+    <AndroidEnableMultiDex>false</AndroidEnableMultiDex>
+    <AndroidUseAapt2>true</AndroidUseAapt2>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
     <DebugSymbols>True</DebugSymbols>
diff --git a/HDL-ON_Android/Other/JPush/JPushFirmBroadcast.cs b/HDL-ON_Android/Other/JPush/JPushFirmBroadcast.cs
index dcf1789..d563368 100644
--- a/HDL-ON_Android/Other/JPush/JPushFirmBroadcast.cs
+++ b/HDL-ON_Android/Other/JPush/JPushFirmBroadcast.cs
@@ -1,15 +1,11 @@
-锘縰sing Android.App;
+锘�
 using Android.Content;
-using Android.OS;
-using Android.Runtime;
-using Android.Views;
-using Android.Widget;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
 
-namespace JPushSample
+using System;
+
+using CN.Jpush.Android.Api;
+
+namespace HDL_ON_Android
 {
 
     [BroadcastReceiver(Enabled = true, Exported = false, Name = "com.hdl.onpro.JPushFirmBroadcast")]
@@ -34,6 +30,31 @@
             cn.jpush.android.TITLE,
             cn.jpush.android.MESSAGE*/
 
+            try
+            {
+                NotificationMessage notificationMessage = new NotificationMessage();
+                String extra = intent.GetStringExtra(JPushInterface.ExtraExtra);
+                String msgId = intent.GetStringExtra(JPushInterface.ExtraMsgId);
+
+                String message = intent.GetStringExtra(JPushInterface.ExtraMessage);
+                String title = intent.GetStringExtra(JPushInterface.ExtraTitle);
+                //  String typePlatform = intent.GetStringExtra(JPushInterface.ExtraTypePlatform);
+
+                notificationMessage.NotificationTitle = title;
+                notificationMessage.NotificationContent = message;
+                notificationMessage.NotificationExtras = extra;
+
+                JPushReceiver.OpenNotification(context, notificationMessage);
+
+            }
+            catch
+            {
+
+            }
+
+
+
+
 
         }
     }
diff --git a/HDL-ON_Android/Other/JPush/JPushOpenClickActivity.cs b/HDL-ON_Android/Other/JPush/JPushOpenClickActivity.cs
index 31b9aca..8fd8f2e 100644
--- a/HDL-ON_Android/Other/JPush/JPushOpenClickActivity.cs
+++ b/HDL-ON_Android/Other/JPush/JPushOpenClickActivity.cs
@@ -1,19 +1,16 @@
 锘縰sing Android.App;
 using Android.Content;
 using Android.OS;
-using Android.Runtime;
-using Android.Views;
-using Android.Widget;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
+
 using Com.Hdl.ON.Jpush.Androidjpush;
 
-namespace JPushSample
+using Android.Views;
+
+namespace HDL_ON_Android
 {
-    [Activity(LaunchMode = Android.Content.PM.LaunchMode.SingleTop,
-            Exported = true, Enabled = true, Name = "com.hdl.onpro.JPushOpenClickActivity")]
+    [Activity(
+            Exported = true, Enabled = true, Name = "com.hdl.onpro.JPushOpenClickActivity"
+        , Theme = "@android:style/Theme.Translucent.NoTitleBar", TaskAffinity = ":jpushopenclick")]
     [IntentFilter(new string[] { "com.hdl.onpro.JPushOpenClickActivity", Intent.ActionView },
          Categories = new string[]
         {
@@ -27,31 +24,31 @@
         protected override void OnCreate(Bundle savedInstanceState)
         {
             base.OnCreate(savedInstanceState);
+            View v = new View(this);
+            SetContentView(v);
+            HandleOpenClick(Intent);
 
         }
 
-        protected void HandleOpenClick()
+        protected void HandleOpenClick(Intent intent)
         {
-            Intent intent = new Intent();
-            intent.SetAction("com.hdl.onpro.jpush.firm.NOTIFICATION_OPENED");
+            Intent broadcastIntent = new Intent();
+            broadcastIntent.SetAction("com.hdl.onpro.jpush.firm.NOTIFICATION_OPENED");
             ComponentName componentName = new ComponentName(PackageName, "com.hdl.onpro.JPushFirmBroadcast");
 
             if (Build.VERSION.SdkInt >= BuildVersionCodes.O)
             {
-                intent.SetComponent(componentName);
+                broadcastIntent.SetComponent(componentName);
             }
-
-
-            this.SendBroadcast(intent);
-            FirmOpenClickHelper.Instance.HandleOpenClick(this, Intent, intent);
+            FirmOpenClickHelper.Instance.HandleOpenClick(this, intent, broadcastIntent);
             Finish();
+
         }
 
         protected override void OnNewIntent(Intent intent)
         {
             base.OnNewIntent(intent);
-            Intent = intent;
-            HandleOpenClick();
+            HandleOpenClick(intent);
 
         }
     }
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
diff --git a/HDL-ON_Android/Properties/AndroidManifest.xml b/HDL-ON_Android/Properties/AndroidManifest.xml
index be23ce9..fb52414 100644
--- a/HDL-ON_Android/Properties/AndroidManifest.xml
+++ b/HDL-ON_Android/Properties/AndroidManifest.xml
@@ -87,6 +87,7 @@
 			<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" />
 		</provider>
 		<!--鏋佸厜鎺ㄩ��-->
+		<provider android:name="Shared.Droid.JPush.HmsContentProvider" android:authorities="${applicationId}.hmspushprovider" android:exported="false"></provider>
 		<!-- Required SDK 鏍稿績鍔熻兘-->
 		<!-- 鍙厤缃� android:process 鍙傛暟灏� PushService 鏀惧湪鍏朵粬杩涚▼涓� -->
 		<service android:name="cn.jpush.android.service.PushService" android:enabled="true" android:exported="false">
@@ -161,6 +162,8 @@
 				<category android:name="com.hdl.onpro" />
 			</intent-filter>
 		</activity>
+
+
 		<!-- Required. For publish channel feature -->
 		<!-- JPUSH_CHANNEL 鏄负浜嗘柟渚垮紑鍙戣�呯粺璁� APK 鍒嗗彂娓犻亾銆�-->
 		<!-- 渚嬪: -->
diff --git a/HDL_APP_Project.sln b/HDL_APP_Project.sln
index 00aa2cc..429707e 100644
--- a/HDL_APP_Project.sln
+++ b/HDL_APP_Project.sln
@@ -27,8 +27,10 @@
 	GlobalSection(ProjectConfigurationPlatforms) = postSolution
 		{09712674-2A38-407B-B1E2-560B2C352F9A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{09712674-2A38-407B-B1E2-560B2C352F9A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{09712674-2A38-407B-B1E2-560B2C352F9A}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
 		{09712674-2A38-407B-B1E2-560B2C352F9A}.Debug|iPhone.ActiveCfg = Debug|Any CPU
 		{09712674-2A38-407B-B1E2-560B2C352F9A}.Debug|iPhone.Build.0 = Debug|Any CPU
+		{09712674-2A38-407B-B1E2-560B2C352F9A}.Debug|iPhone.Deploy.0 = Debug|Any CPU
 		{09712674-2A38-407B-B1E2-560B2C352F9A}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
 		{09712674-2A38-407B-B1E2-560B2C352F9A}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
 		{09712674-2A38-407B-B1E2-560B2C352F9A}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -38,7 +40,6 @@
 		{09712674-2A38-407B-B1E2-560B2C352F9A}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
 		{09712674-2A38-407B-B1E2-560B2C352F9A}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
 		{D998E133-F0DD-4760-BE3C-461632F54DA4}.Debug|Any CPU.ActiveCfg = Debug|iPhoneSimulator
-		{D998E133-F0DD-4760-BE3C-461632F54DA4}.Debug|Any CPU.Build.0 = Debug|iPhoneSimulator
 		{D998E133-F0DD-4760-BE3C-461632F54DA4}.Debug|iPhone.ActiveCfg = Debug|iPhone
 		{D998E133-F0DD-4760-BE3C-461632F54DA4}.Debug|iPhone.Build.0 = Debug|iPhone
 		{D998E133-F0DD-4760-BE3C-461632F54DA4}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
@@ -50,7 +51,6 @@
 		{D998E133-F0DD-4760-BE3C-461632F54DA4}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
 		{D998E133-F0DD-4760-BE3C-461632F54DA4}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
 		{2DDF4C3C-6998-432E-9F43-6786D82F0630}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{2DDF4C3C-6998-432E-9F43-6786D82F0630}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{2DDF4C3C-6998-432E-9F43-6786D82F0630}.Debug|iPhone.ActiveCfg = Debug|Any CPU
 		{2DDF4C3C-6998-432E-9F43-6786D82F0630}.Debug|iPhone.Build.0 = Debug|Any CPU
 		{2DDF4C3C-6998-432E-9F43-6786D82F0630}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU

--
Gitblit v1.8.0