wxr
2024-12-02 ea0b1e8e5f43c5fd0a7d479e25ede3b8cbea464a
HDL-ON_Android/Other/JPush/JPushReceiver.cs
@@ -7,25 +7,41 @@
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.santan.smartcontrol"
    })]
    public class JPushReceiver : JPushMessageReceiver
    //[BroadcastReceiver(Enabled = true, Exported = false)]
    //[Android.App.IntentFilter(new string[]
    //{
    //    "cn.jpush.android.intent.RECEIVE_MESSAGE"
    //},
    //Categories = new string[]
    //{
    //    "com.santan.smartcontrol"
    //})]
    [Android.App.Service(Enabled = true, Exported = false)]
    [Android.App.IntentFilter(
        new string[] { "cn.jpush.android.intent.SERVICE_MESSAGE" },
        Categories = new string[]
        {
            "com.santan.smartcontrol"
        })]
    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,11 +50,8 @@
        /// <param name="notificationMessage"></param>
        public override void OnNotifyMessageOpened(Context context, NotificationMessage notificationMessage)
        {
            //2020-12-23 解决点击通知栏打开不了APP问题
            //base.OnNotifyMessageOpened(context, notificationMessage);
            OpenNotification(context, notificationMessage);
            OpenNotification(context, notificationMessage,true);
        }
        /// <summary>
@@ -49,7 +62,7 @@
        public override void OnNotifyMessageArrived(Context context, NotificationMessage notificationMessage)
        {
            base.OnNotifyMessageArrived(context, notificationMessage);
            var pushMes = new JPushMessageInfo()
            {
                Title = notificationMessage.NotificationTitle,
@@ -115,7 +128,7 @@
        public override void OnRegister(Context context, string p1)
        {
            base.OnRegister(context, p1);
            Utlis.WriteLine("JPushOnRegister: " + p1);
            Utlis.WriteLine("极光推送-注册成功回调: " + p1);
        }
        /// <summary>
@@ -123,7 +136,7 @@
        /// </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
            {
@@ -131,7 +144,8 @@
                {
                    Title = notificationMessage.NotificationTitle,
                    Content = notificationMessage.NotificationContent,
                    Extras = notificationMessage.NotificationExtras
                    Extras = notificationMessage.NotificationExtras,
                    isNotificationGoing = isNotification
                };
                var jpushExpandData = GetJPushExpandData(pushMes);
@@ -148,15 +162,15 @@
                Utlis.WriteLine("PushMes extras : " + pushMes.Extras);
                Utlis.WriteLine("PushMes HomeId : " + pushMes.HomeId);
                if (Shared.Application.Activity==null)
                if (Shared.Application.Activity == null)
                {
                    Intent i = new Intent(context, typeof(SplashActivity));//Intent intent=new Intent( 起始组件对象 , 目标 Service.class);
                    Intent i = new Intent(context, typeof(SplashActivity));
                    i.SetFlags(ActivityFlags.NewTask);
                    context.StartActivity(i);
                }
                else
                {
                    Intent i = new Intent(context, typeof(BaseActivity));//Intent intent=new Intent( 起始组件对象 , 目标 Service.class);
                    Intent i = new Intent(context, typeof(BaseActivity));
                    i.SetFlags(ActivityFlags.NewTask);
                    context.StartActivity(i);
                }