From 17355977e81bb1f93862b5201424f60af9d093cf Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期六, 05 十二月 2020 16:21:44 +0800 Subject: [PATCH] 2020-12-05 1.增加苹果推送处理。2.暂时通过推送实现,增加挤下线功能。 --- HDL-ON_Android/Other/JPush/JPushReceiver.cs | 147 +++++++++++++++++++++++++------------------------ 1 files changed, 75 insertions(+), 72 deletions(-) diff --git a/HDL-ON_Android/Other/JPush/JPushReceiver.cs b/HDL-ON_Android/Other/JPush/JPushReceiver.cs index 61b99f9..f24b091 100644 --- a/HDL-ON_Android/Other/JPush/JPushReceiver.cs +++ b/HDL-ON_Android/Other/JPush/JPushReceiver.cs @@ -1,17 +1,9 @@ -锘縰sing System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using Android.App; +锘� using Android.Content; -using Android.OS; -using Android.Runtime; -using Android.Views; -using Android.Widget; using CN.Jpush.Android.Api; using CN.Jpush.Android.Service; using HDL_ON; +using HDL_ON.DAL.Server; using Shared; namespace HDL_ON_Android @@ -40,11 +32,7 @@ { base.OnNotifyMessageOpened(context, notificationMessage); - //App.Paras = p1.NotificationExtras; - - //Utlis.ShowTip("鏀跺埌鎺ㄩ�侊細" + p1.NotificationExtras); - Utlis.WriteLine("鏋佸厜OnNotifyMessageOpened: " + notificationMessage.NotificationContent); - Utlis.WriteLine("鏋佸厜OnNotifyMessageOpened: " + notificationMessage.NotificationExtras); + OpenNotification(context, notificationMessage); } /// <summary> @@ -55,8 +43,18 @@ public override void OnNotifyMessageArrived(Context context, NotificationMessage notificationMessage) { base.OnNotifyMessageArrived(context, notificationMessage); - Utlis.WriteLine("鏋佸厜OnNotifyMessageArrived: " + notificationMessage.NotificationContent); - Utlis.WriteLine("鏋佸厜OnNotifyMessageArrived: " + notificationMessage.NotificationExtras); + + var pushMes = new JPushMessageInfo() + { + Title = notificationMessage.NotificationTitle, + Content = notificationMessage.NotificationContent, + Extras = notificationMessage.NotificationExtras + }; + System.Console.WriteLine("PushMes title : " + pushMes.Title); + System.Console.WriteLine("PushMes message : " + pushMes.Content); + System.Console.WriteLine("PushMes extras : " + pushMes.Extras); + + HDLCommon.Current.AdjustPushMessage(pushMes); } /// <summary> @@ -72,76 +70,81 @@ } ///// <summary> - ///// 鏀跺埌鑷畾涔夋秷鎭洖璋� + ///// 澶勭悊鏋佸厜淇℃伅鎺ㄩ�� ///// </summary> - ///// <param name="p0"></param> - ///// <param name="p1"></param> - //public override void OnMessage(Context p0, CustomMessage p1) + ///// <param name="title">鏍囬</param> + ///// <param name="message">淇℃伅</param> + ///// <param name="extras">璐熻浇鏁版嵁</param> + //public void AdjustJiguangMsgPush(JPushMessageInfo JPushMessageInfo) //{ - // base.OnMessage(p0, p1); + // try + // { + - // Utlis.WriteLine("鏋佸厜OnMessage: " + p1.Message.ToString()); + // 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> - /// 澶勭悊鏋佸厜淇℃伅鎺ㄩ�� - /// </summary> - /// <param name="title">鏍囬</param> - /// <param name="message">淇℃伅</param> - /// <param name="extras">璐熻浇鏁版嵁</param> - public void AdjustJiguangMsgPush(NotificationMessage notificationMessage) - { - string title = notificationMessage.NotificationTitle; - System.Console.WriteLine(TAG, " title : " + title); - string message = notificationMessage.NotificationContent; - System.Console.WriteLine(TAG, "message : " + message); - string extras = notificationMessage.NotificationExtras; - System.Console.WriteLine(TAG, "extras : " + extras); - - - if (extras.Contains("Offline") == true) - { - - Shared.Application.RunOnMainThread(() => - { - //姝ゅ笎鍙峰凡鍦ㄥ埆澶勭櫥褰�,鎮ㄨ杩笅绾� - //ShowAlert("姝ゅ笎鍙峰凡鍦ㄥ埆澶勭櫥褰�,鎮ㄨ杩笅绾�"); - //璐﹀彿鍦ㄥ埆澶勭櫥闄嗭紝琚涪涓嬬嚎 璺宠浆鍒扮櫥褰曢〉闈� - HDLCommon.Current.ShowAlert(Language.StringByID(StringId.LoggedOnOtherDevices)); - - }); - return; - } - } /// <summary> /// 鎵撳紑娑堟伅鏄剧ず鐣岄潰 /// </summary> - /// <param name="context">Context.</param> - /// <param name="bundle">Bundle.</param> - private void OpenNotification(Context context, Bundle bundle) + /// <param name="context"></param> + /// <param name="notificationMessage"></param> + private void OpenNotification(Context context, NotificationMessage notificationMessage) { - - Intent i = new Intent(context, typeof(BaseActivity));//Intent intent=new Intent( 璧峰缁勪欢瀵硅薄 , 鐩爣 Service.class); - i.PutExtras(bundle); - i.SetFlags(ActivityFlags.NewTask); - context.StartActivity(i); - - String extras = bundle.GetString(JPushInterface.ExtraExtra); - //String myValue = ""; try { - + var pushMes = new JPushMessageInfo() + { + Title = notificationMessage.NotificationTitle, + Content = notificationMessage.NotificationContent, + Extras = notificationMessage.NotificationExtras + }; + System.Console.WriteLine("PushMes title : " + pushMes.Title); + System.Console.WriteLine("PushMes message : " + pushMes.Content); + System.Console.WriteLine("PushMes extras : " + pushMes.Extras); + 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 (Exception e) + catch { - System.Console.WriteLine("JPush", "Unexpected: extras is not a valid json", e); - return; - } - + } } } -- Gitblit v1.8.0