From a4534a17ec23a4effce2df59d9bd297a313c8168 Mon Sep 17 00:00:00 2001 From: wxr <wxr@hdlchina.com.cn> Date: 星期五, 19 七月 2024 17:55:32 +0800 Subject: [PATCH] 极光推送Sdk更新,不支持厂商 --- HDL-ON_Android/Other/JPush/JPushReceiver.cs | 128 ++++++++++++++++-------------------------- 1 files changed, 48 insertions(+), 80 deletions(-) diff --git a/HDL-ON_Android/Other/JPush/JPushReceiver.cs b/HDL-ON_Android/Other/JPush/JPushReceiver.cs index 9438176..7c725ec 100644 --- a/HDL-ON_Android/Other/JPush/JPushReceiver.cs +++ b/HDL-ON_Android/Other/JPush/JPushReceiver.cs @@ -1,31 +1,46 @@ 锘� using System; -using Android.App; using Android.Content; using CN.Jpush.Android.Api; using CN.Jpush.Android.Service; 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[] - { - "com.hdl.onpro" - })] - public class JPushReceiver : JPushMessageReceiver + //[BroadcastReceiver(Enabled = true, Exported = false)] + //[Android.App.IntentFilter(new string[] + //{ + // "cn.jpush.android.intent.RECEIVE_MESSAGE" + //}, + //Categories = new string[] + //{ + // "com.jinlu.onpro" + //})] + + + [Android.App.Service(Enabled = true, Exported = false)] + [Android.App.IntentFilter( + new string[] { "cn.jpush.android.intent.SERVICE_MESSAGE" }, + Categories = new string[] + { + "com.jinlu.onpro" + })] + public class JPushReceiver : JPushMessageService { private static string TAG = "JPushReceiver"; + + public override void OnMessage(Context p0, CustomMessage p1) + { + Console.WriteLine("鏀跺埌鏋佸厜鎺ㄩ��"); + base.OnMessage(p0, p1); + + } + /// <summary> /// 鐢ㄦ埛鐐瑰嚮鎵撳紑浜嗛�氱煡 /// 鐐瑰嚮閫氱煡鍥炶皟 @@ -34,9 +49,10 @@ /// <param name="notificationMessage"></param> public override void OnNotifyMessageOpened(Context context, NotificationMessage notificationMessage) { + + //2020-12-23 瑙e喅鐐瑰嚮閫氱煡鏍忔墦寮�涓嶄簡APP闂 //base.OnNotifyMessageOpened(context, notificationMessage); - OpenNotification(context, notificationMessage); } @@ -63,6 +79,12 @@ pushMes.expantContent = jpushExpandData.expantContent; pushMes.HomeId = jpushExpandData.homeId; Utlis.WriteLine("PushMes messageType : " + pushMes.messageType); + } + + if (!string.IsNullOrEmpty(pushMes.spk))//鑷爺鍙瀵硅闇�瑕佽褰曟椂闂村弽鍛� + { + UserInfo.Current.pushMessageInfo = pushMes; + UserInfo.Current.inCall = DateTime.Now; } Utlis.WriteLine("PushMes title : " + pushMes.Title); @@ -108,44 +130,8 @@ public override void OnRegister(Context context, string p1) { base.OnRegister(context, p1); - Utlis.WriteLine("JPushOnRegister: " + p1); + Utlis.WriteLine("鏋佸厜鎺ㄩ��-娉ㄥ唽鎴愬姛鍥炶皟: " + p1); } - - ///// <summary> - ///// 澶勭悊鏋佸厜淇℃伅鎺ㄩ�� - ///// </summary> - ///// <param name="title">鏍囬</param> - ///// <param name="message">淇℃伅</param> - ///// <param name="extras">璐熻浇鏁版嵁</param> - //public void AdjustJiguangMsgPush(JPushMessageInfo JPushMessageInfo) - //{ - // try - // { - // if (JPushMessageInfo.Extras.Contains("Offline") == true) - // { - // Shared.Application.RunOnMainThread(() => - // { - // //璐﹀彿鍦ㄥ埆澶勭櫥闄嗭紝琚涪涓嬬嚎 璺宠浆鍒扮櫥褰曢〉闈� - // new Alert(Language.StringByID(StringId.Tip), Language.StringByID(StringId.LoggedOnOtherDevices), Language.StringByID(StringId.Close)).Show(); - // //2020-12-04 寰呭鍔犻��鍑虹櫥褰曟搷浣� - // }); - // return; - // } - // else - // { - // Shared.Application.RunOnMainThread(() => - // { - // new Alert(JPushMessageInfo.Title, JPushMessageInfo.Content, Language.StringByID(StringId.Close)).Show(); - // }); - // return; - - // } - // } - // catch - // { - - // } - //} /// <summary> /// 鎵撳紑娑堟伅鏄剧ず鐣岄潰.010000 @@ -154,7 +140,6 @@ /// <param name="notificationMessage"></param> public static void OpenNotification(Context context, NotificationMessage notificationMessage) { - try { var pushMes = new JPushMessageInfo() @@ -178,46 +163,29 @@ Utlis.WriteLine("PushMes extras : " + pushMes.Extras); 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); + if (Shared.Application.Activity == null) + { + Intent i = new Intent(context, typeof(SplashActivity)); + i.SetFlags(ActivityFlags.NewTask); + context.StartActivity(i); + } + else + { + Intent i = new Intent(context, typeof(BaseActivity)); + 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 { } - //catch (Exception ex) - //{ - // Utlis.WriteLine(ex.ToString()); - //} } - - public static void AdjustPushMessage(JPushMessageInfo pushMes) { - new System.Threading.Thread(new System.Threading.ThreadStart(() => { while (MainPage.BasePageView == null) -- Gitblit v1.8.0