/** * 通知被打开结果反馈 * * @param context * APP上下文对象 * @param message * 被打开的消息对象 */ public override void OnNotifactionClickedResult(Context context, XGPushClickedResult message) { if (context == null || message == null) { return; } String text = "通知被打开 :" + message; // 获取自定义key-value String customContent = message.CustomContent; if (!string.IsNullOrEmpty(customContent)) { try { JSONObject obj = new JSONObject(customContent); // key1为前台配置的key if (!obj.IsNull("key")) { String value = obj.GetString("key"); Log.Debug(LogTag, "get custom value:" + value); } // ... } catch (JSONException e) { e.PrintStackTrace(); } } // APP自主处理的过程。。。 Log.Debug(LogTag, text); // show(context, text); }
public override void OnNotifactionClickedResult(Context context, XGPushClickedResult message) { NotificationManager notificationManager = (NotificationManager)context.GetSystemService(Context.NotificationService); notificationManager.CancelAll(); if (context == null || message == null) { return; } if (message.ActionType == XGPushClickedResult.NotifactionClickedType) { // 通知在通知栏被点击啦。。。。。 // APP自己处理点击的相关动作 // 获取自定义key-value string customContent = message.CustomContent; if (customContent != null && customContent.Length != 0) { MessagingService.Current.SendMessage(MessageKeys.NavigateNotification, customContent); } } else if (message.ActionType == XGPushClickedResult.NotifactionDeletedType) { // 通知被清除啦。。。。 // APP自己处理通知被清除后的相关动作 } }
protected override void OnStart() { base.OnStart(); XGPushClickedResult click = XGPushManager.OnActivityStarted(this); if (click != null) { // 判断是否来自信鸽的打开方式 Toast.MakeText(this, "通知被点击:" + click.ToString(), ToastLength.Short).Show(); String customContent = click.CustomContent; // 获取自定义key-value if (!string.IsNullOrEmpty(customContent)) { try { JSONObject json = new JSONObject(customContent); Log.Debug("TPush", "自定义key-value:" + json); // 获取在线自定义key-value // key1为下发的自定义key-value String customValue1 = json.GetString("key1"); // 。。。。 } catch (JSONException e) { e.PrintStackTrace(); } } } }
public override void OnNotifactionClickedResult(Context context, XGPushClickedResult message) { NotificationManager notificationManager = (NotificationManager)context.GetSystemService(Context.NotificationService); notificationManager.CancelAll(); if (context == null || message == null) { return; } if (message.ActionType == XGPushClickedResult.NotifactionClickedType) { // The notification was clicked in the notification bar.。。。。。 // The APP itself handles the related actions of the click // Get custom key-value string customContent = message.CustomContent; if (customContent != null && customContent.Length != 0) { MessagingService.Current.SendMessage(MessageKeys.NavigateNotification, customContent); } } else if (message.ActionType == XGPushClickedResult.NotifactionDeletedType) { // The notice was cleared。。。。 // The APP itself processes the related actions after the notification is cleared. } }