protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_main); InitializeViews(); //OnCreate() method will be triggered if this activity is not in foreground or user clicks on actions var notificationData = RemoteMessageUtils.ExtractNotificationData(Intent); if (notificationData != null) { log.Info("NotificationData(OnCreate)", notificationData.DictionaryToString()); if (notificationData.ContainsKey(NotificationConstants.Action)) { string action = notificationData[NotificationConstants.Action]; if (action == "Yes")//Custom action { //If user clicks on "Yes" action log.Info("Notification", "Clicked \"Yes\""); } else if (action == "No")//Custom action { //If user clicks on "No" action log.Info("Notification", "Clicked \"No\""); } } } }
/// <summary> /// Get last notification's bundle /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnClickGetInitialNotification(object sender, EventArgs e) { var notificationData = RemoteMessageUtils.ExtractNotificationData(Intent); if (notificationData != null) { log.Info("NotificationData", notificationData.DictionaryToString()); } }
protected override void OnNewIntent(Intent intent) { base.OnNewIntent(intent); //OnNewIntent() method will be triggered if there is no action and this activity is in foreground. var notificationData = RemoteMessageUtils.ExtractNotificationData(intent); if (notificationData != null) { log.Info("NotificationData(OnNewIntent)", notificationData.DictionaryToString()); } }
public override void OnMessageReceived(RemoteMessage message) { //It get triggered when data message comes or a notification comes which as foreground attributes false string MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; Log.Info(MethodName, RemoteMessageUtils.FromMap(message).DictionaryToString()); Intent intent = new Intent(); intent.SetAction(HMSPushAction); intent.PutExtra(HMSPushReceiver.Method, System.Reflection.MethodBase.GetCurrentMethod().Name); intent.PutExtra(HMSPushReceiver.Message, message); SendBroadcast(intent); }
public override void OnClickAction(Intent notification) { var notificationData = RemoteMessageUtils.ExtractNotificationData(notification); if (notificationData != null) { Log.Info(Tag, notificationData.DictionaryToString()); Intent intent = new Intent(); intent.SetAction(HMSActionReceiver); intent.PutExtras(notification); SendBroadcast(intent); } }
public override void OnReceive(Context context, Intent intent) { var notificationData = RemoteMessageUtils.ExtractNotificationData(intent); if (notificationData != null) { Log.Info(Tag, notificationData.DictionaryToString()); string action = notificationData[NotificationConstants.Action]; if (action == "Yes")//Custom action { //If user clicks on "Yes" action NotificationController.InvokeApp(context, intent.Extras.GetBundle(NotificationConstants.Notification)); } } }