wxr
2024-09-27 acc8caee31c4be90bd38d1af18136b0e84f6fe94
HDL-ON_Android/Other/JPush/JPushReceiver.cs
@@ -3,6 +3,7 @@
using Android.Content;
using CN.Jpush.Android.Api;
using CN.Jpush.Android.Service;
using Com.Hdl.Hdllinphonesdk;
using HDL_ON;
using HDL_ON.DAL.Server;
using Shared;
@@ -17,18 +18,21 @@
    //},
    //Categories = new string[]
    //{
    //    "com.jinlu.onpro"
    //    "com.hdl.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
    //[Android.App.Service(Enabled = true)]
    //[Android.App.IntentFilter(
    //    new string[] { "cn.jpush.android.intent.SERVICE_MESSAGE" },
    //    Categories = new string[]
    //    {
    //        "com.hdl.onpro"
    //    })]
    [BroadcastReceiver(Enabled = true, Exported = true)]
    [Android.App.IntentFilter(new string[] { "cn.jpush.android.intent.SERVICE_MESSAGE" }, Categories = new string[] { "com.hdl.onpro" })]
    public class JPushReceiver : JPushMessageReceiver// JPushMessageService
    {
@@ -49,11 +53,8 @@
        /// <param name="notificationMessage"></param>
        public override void OnNotifyMessageOpened(Context context, NotificationMessage notificationMessage)
        {
            //2020-12-23 解决点击通知栏打开不了APP问题
            //base.OnNotifyMessageOpened(context, notificationMessage);
            OpenNotification(context, notificationMessage);
            MainPage.Log("接收到推送:点击通知回调");
            OpenNotification(context, notificationMessage,true);
        }
        /// <summary>
@@ -78,14 +79,10 @@
                pushMes.messageType = jpushExpandData.messageType;
                pushMes.expantContent = jpushExpandData.expantContent;
                pushMes.HomeId = jpushExpandData.homeId;
                Utlis.WriteLine("PushMes messageType : " + pushMes.messageType);
                Utlis.WriteLine("收到通知回调\r\nPushMes messageType : " + pushMes.messageType);
            }
            if (!string.IsNullOrEmpty(pushMes.spk))//自研可视对讲需要记录时间反呼
            {
                UserInfo.Current.pushMessageInfo = pushMes;
                UserInfo.Current.inCall = DateTime.Now;
            }
            Utlis.WriteLine("PushMes title : " + pushMes.Title);
            Utlis.WriteLine("PushMes message : " + pushMes.Content);
@@ -130,7 +127,6 @@
        public override void OnRegister(Context context, string p1)
        {
            base.OnRegister(context, p1);
            Utlis.WriteLine("极光推送-注册成功回调: " + p1);
        }
        /// <summary>
@@ -138,15 +134,17 @@
        /// </summary>
        /// <param name="context"></param>
        /// <param name="notificationMessage"></param>
        public static void OpenNotification(Context context, NotificationMessage notificationMessage)
        public static void OpenNotification(Context context, NotificationMessage notificationMessage,bool isNotification = false)
        {
            try
            {
                MainPage.Log("接收到推送:打开消息显示界面");
                var pushMes = new JPushMessageInfo()
                {
                    Title = notificationMessage.NotificationTitle,
                    Content = notificationMessage.NotificationContent,
                    Extras = notificationMessage.NotificationExtras
                    Extras = notificationMessage.NotificationExtras,
                    isNotificationGoing = isNotification
                };
                var jpushExpandData = GetJPushExpandData(pushMes);
@@ -172,11 +170,14 @@
                else
                {
                    Intent i = new Intent(context, typeof(BaseActivity));
                    i.SetFlags(ActivityFlags.SingleTop);
                    i.SetFlags(ActivityFlags.ClearTop);
                    i.SetFlags(ActivityFlags.NewTask);
                    context.StartActivity(i);
                }
                //解析msg
                AdjustPushMessage(pushMes);
            }
            catch
            {