From 797358fee56a79b8c783aebb87b275f2e8ad1334 Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期一, 08 三月 2021 09:21:07 +0800
Subject: [PATCH] Merge branch 'CJL' into temp-wxr
---
HDL-ON_Android/Other/JPush/JPushReceiver.cs | 205 +++++++++++++++++++++++++++++++++------------------
1 files changed, 132 insertions(+), 73 deletions(-)
diff --git a/HDL-ON_Android/Other/JPush/JPushReceiver.cs b/HDL-ON_Android/Other/JPush/JPushReceiver.cs
index 61b99f9..ff8a03b 100644
--- a/HDL-ON_Android/Other/JPush/JPushReceiver.cs
+++ b/HDL-ON_Android/Other/JPush/JPushReceiver.cs
@@ -1,17 +1,10 @@
-锘縰sing System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-using Android.App;
+锘�
+using System;
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
@@ -38,13 +31,10 @@
/// <param name="notificationMessage"></param>
public override void OnNotifyMessageOpened(Context context, NotificationMessage notificationMessage)
{
- base.OnNotifyMessageOpened(context, notificationMessage);
+ //2020-12-23 瑙e喅鐐瑰嚮閫氱煡鏍忔墦寮�涓嶄簡APP闂
+ //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,9 +45,50 @@
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
+ };
+
+ var jpushExpandData = GetJPushExpandData(pushMes);
+ if (jpushExpandData != null && jpushExpandData.messageType != null)
+ {
+ pushMes.messageType = jpushExpandData.messageType;
+ Utlis.WriteLine("PushMes messageType : " + pushMes.messageType);
+ }
+
+ Utlis.WriteLine("PushMes title : " + pushMes.Title);
+ Utlis.WriteLine("PushMes message : " + pushMes.Content);
+ Utlis.WriteLine("PushMes extras : " + pushMes.Extras);
+
+ HDLCommon.Current.AdjustPushMessage(pushMes);
}
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="pushMes"></param>
+ /// <returns></returns>
+ ExpandData GetJPushExpandData(JPushMessageInfo pushMes)
+ {
+ try
+ {
+ if (pushMes.Extras != null)
+ {
+ var jpushExpandData = Newtonsoft.Json.JsonConvert.DeserializeObject<JPushExpandData>(pushMes.Extras.ToString());
+ return Newtonsoft.Json.JsonConvert.DeserializeObject<ExpandData>(jpushExpandData.expandData);
+ }
+ return null;
+ }
+ catch
+ {
+ return null;
+ }
+ }
+
/// <summary>
/// 娉ㄥ唽鎴愬姛鍥炶皟
@@ -72,76 +103,104 @@
}
///// <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
+ };
+ var jpushExpandData = GetJPushExpandData(pushMes);
+ if (jpushExpandData != null && jpushExpandData.messageType != null)
+ {
+ pushMes.messageType = jpushExpandData.messageType;
+ Utlis.WriteLine("PushMes messageType : " + pushMes.messageType);
+ }
+
+ Utlis.WriteLine("PushMes title : " + pushMes.Title);
+ Utlis.WriteLine("PushMes message : " + pushMes.Content);
+ Utlis.WriteLine("PushMes extras : " + pushMes.Extras);
+ 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);
+ // }
+ //});
}
- catch (Exception e)
+ catch
{
- System.Console.WriteLine("JPush", "Unexpected: extras is not a valid json", e);
- return;
- }
-
+ }
+ //catch (Exception ex)
+ //{
+ // Utlis.WriteLine(ex.ToString());
+ //}
}
}
--
Gitblit v1.8.0