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 Shared;
|
|
namespace HDL_ON_Android
|
{
|
|
[BroadcastReceiver(Enabled = true, Exported = false)]
|
[Android.App.IntentFilter(new string[]
|
{
|
"cn.jpush.android.intent.RECEIVE_MESSAGE"
|
},
|
Categories=new string[]
|
{
|
"com.hdl.onpro"
|
})]
|
public class JPushReceiver : JPushMessageReceiver
|
{
|
|
private static string TAG = "JPushReceiver";
|
/// <summary>
|
/// 用户点击打开了通知
|
/// 点击通知回调
|
/// </summary>
|
/// <param name="context"></param>
|
/// <param name="notificationMessage"></param>
|
public override void OnNotifyMessageOpened(Context context, NotificationMessage notificationMessage)
|
{
|
base.OnNotifyMessageOpened(context, notificationMessage);
|
|
//App.Paras = p1.NotificationExtras;
|
|
//Utlis.ShowTip("收到推送:" + p1.NotificationExtras);
|
Utlis.WriteLine("极光OnNotifyMessageOpened: " + notificationMessage.NotificationContent);
|
Utlis.WriteLine("极光OnNotifyMessageOpened: " + notificationMessage.NotificationExtras);
|
}
|
|
/// <summary>
|
/// 收到通知回调
|
/// </summary>
|
/// <param name="p0"></param>
|
/// <param name="p1"></param>
|
public override void OnNotifyMessageArrived(Context context, NotificationMessage notificationMessage)
|
{
|
base.OnNotifyMessageArrived(context, notificationMessage);
|
Utlis.WriteLine("极光OnNotifyMessageArrived: " + notificationMessage.NotificationContent);
|
Utlis.WriteLine("极光OnNotifyMessageArrived: " + notificationMessage.NotificationExtras);
|
}
|
|
/// <summary>
|
/// 注册成功回调
|
/// </summary>
|
/// <param name="p0"></param>
|
/// <param name="p1"></param>
|
public override void OnRegister(Context context, string p1)
|
{
|
base.OnRegister(context, p1);
|
|
Utlis.WriteLine("JPushOnRegister: " + p1);
|
}
|
|
///// <summary>
|
///// 收到自定义消息回调
|
///// </summary>
|
///// <param name="p0"></param>
|
///// <param name="p1"></param>
|
//public override void OnMessage(Context p0, CustomMessage p1)
|
//{
|
// base.OnMessage(p0, p1);
|
|
// Utlis.WriteLine("极光OnMessage: " + p1.Message.ToString());
|
//}
|
|
|
/// <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)
|
{
|
|
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
|
{
|
|
|
}
|
catch (Exception e)
|
{
|
System.Console.WriteLine("JPush", "Unexpected: extras is not a valid json", e);
|
return;
|
}
|
|
|
}
|
}
|
|
}
|