From 4c586bb23cdcae56ae4e4c62e90e148dc10b9d90 Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期二, 17 五月 2022 14:19:31 +0800 Subject: [PATCH] Merge branch 'Dev-Branch' into wxr1215 --- HDL-ON_Android/Other/JPush/JPushReceiver.cs | 125 ++++++++++++++++++++++++++--------------- 1 files changed, 80 insertions(+), 45 deletions(-) diff --git a/HDL-ON_Android/Other/JPush/JPushReceiver.cs b/HDL-ON_Android/Other/JPush/JPushReceiver.cs index 9438176..3b0cf2b 100644 --- a/HDL-ON_Android/Other/JPush/JPushReceiver.cs +++ b/HDL-ON_Android/Other/JPush/JPushReceiver.cs @@ -37,8 +37,13 @@ //2020-12-23 瑙e喅鐐瑰嚮閫氱煡鏍忔墦寮�涓嶄簡APP闂 //base.OnNotifyMessageOpened(context, notificationMessage); + //NotificationManager NotifyManager = (NotificationManager)GetSystemService(Context.NotificationService); + //NotificationManager notificationManager = NotifyManager; + OpenNotification(context, notificationMessage); } + + static int msgId = 0; /// <summary> /// 鏀跺埌閫氱煡鍥炶皟 @@ -47,34 +52,59 @@ /// <param name="p1"></param> public override void OnNotifyMessageArrived(Context context, NotificationMessage notificationMessage) { - base.OnNotifyMessageArrived(context, notificationMessage); - - var pushMes = new JPushMessageInfo() + try { - Title = notificationMessage.NotificationTitle, - Content = notificationMessage.NotificationContent, - Extras = notificationMessage.NotificationExtras - }; - var jpushExpandData = GetJPushExpandData(pushMes); - if (jpushExpandData != null && jpushExpandData.messageType != null) - { - pushMes.messageType = jpushExpandData.messageType; - pushMes.expantContent = jpushExpandData.expantContent; - pushMes.HomeId = jpushExpandData.homeId; - Utlis.WriteLine("PushMes messageType : " + pushMes.messageType); + NotificationManager nMgr = (NotificationManager)Shared.Application.Activity.GetSystemService(Context.NotificationService); + if (msgId != 0) + nMgr.Cancel(msgId); + msgId = notificationMessage.NotificationId; + base.OnNotifyMessageArrived(context, notificationMessage); Console.WriteLine("123456789ghjsdjfasdfk"); + + var pushMes = new JPushMessageInfo() + { + Title = notificationMessage.NotificationTitle, + Content = notificationMessage.NotificationContent, + Extras = notificationMessage.NotificationExtras + }; + + var jpushExpandData = GetJPushExpandData(pushMes); + if (jpushExpandData != null && jpushExpandData.messageType != null) + { + pushMes.messageType = jpushExpandData.messageType; + pushMes.expantContent = jpushExpandData.expantContent;//spk + pushMes.HomeId = jpushExpandData.homeId; + Utlis.WriteLine("PushMes messageType : " + pushMes.messageType); + } + + Utlis.WriteLine("PushMes title : " + pushMes.Title); + Utlis.WriteLine("PushMes message : " + pushMes.Content); + Utlis.WriteLine("PushMes extras : " + pushMes.Extras); + Utlis.WriteLine("PushMes HomeId : " + pushMes.HomeId); + + //UserInfo.Current.PushMesTitle = pushMes.Title; + //UserInfo.Current.PushMesMessage = pushMes.Content; + //UserInfo.Current.PushMesExtras = pushMes.Extras; + //UserInfo.Current.pushMesMessageType = pushMes.messageType; + //UserInfo.Current.pushMesExpantContent = pushMes.expantContent; + //UserInfo.Current.PushMesHomeId = pushMes.HomeId; + UserInfo.Current.pushMessageInfo = pushMes; + if (!string.IsNullOrEmpty(pushMes.spk))//鑷爺鍙瀵硅闇�瑕佽褰曟椂闂村弽鍛� + UserInfo.Current.inCall = DateTime.Now; + + if (!MainPage.IsEnterBackground) + { + //NotificationManager nMgr = (NotificationManager)Shared.Application.Activity.GetSystemService(Context.NotificationService); + //nMgr.CancelAll(); + Shared.Application.RunOnMainThread(() => + { + HDLCommon.Current.AdjustPushMessage(pushMes); + }); + } } - - 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(() => - { - HDLCommon.Current.AdjustPushMessage(pushMes); - }); - + catch (Exception wexx) { + Console.WriteLine("safsdf"+wexx.Message); + } } /// <summary> @@ -183,25 +213,30 @@ 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); - // } - //}); + 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); + // } + //}); + if (!MainPage.IsEnterBackground) + { + NotificationManager nMgr = (NotificationManager)Shared.Application.Activity.GetSystemService(Context.NotificationService); + nMgr.CancelAll(); + } } catch { @@ -222,7 +257,7 @@ { while (MainPage.BasePageView == null) { - System.Threading.Thread.Sleep(300); + System.Threading.Thread.Sleep(300); } Shared.Application.RunOnMainThread(() => { -- Gitblit v1.8.0