Ejemplo n.º 1
0
        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\"");
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <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());
            }
        }
Ejemplo n.º 3
0
        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());
            }
        }
Ejemplo n.º 4
0
        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);
            }
        }
Ejemplo n.º 5
0
        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));
                }
            }
        }