| | |
| | | using 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 |
| | |
| | | { |
| | | 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> |
| | |
| | | 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> |
| | |
| | | } |
| | | |
| | | ///// <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; |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | } |
| | | |