Example #1
0
        void Current_OnNotificationOpened(object source, FirebasePushNotificationResponseEventArgs e)
        {
            try
            {
                System.Diagnostics.Debug.WriteLine("Opened");

                foreach (var data in e.Data)
                {
                    System.Diagnostics.Debug.WriteLine($"{data.Key} : {data.Value}");
                }

                if (!string.IsNullOrEmpty(e.Identifier))
                {
                    System.Diagnostics.Debug.WriteLine($"ActionId: {e.Identifier}");

                    Device.BeginInvokeOnMainThread(() => {
                        lblMessage.Text = e.Identifier;
                    });
                }
                else if (e.Data.ContainsKey("aps.alert.title"))
                {
                    Device.BeginInvokeOnMainThread(() => {
                        lblMessage.Text = $"{e.Data["aps.alert.title"]}";
                    });
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Excepton on Opened:" + ex.Message);
            }
        }
Example #2
0
        private void FirebasePushNotification_OnNotificationOpened(object source, FirebasePushNotificationResponseEventArgs e)
        {
            if (!IsNotificationData(e.Data))
            {
                return;
            }

            var args = new NotificationEventArgs(new Dictionary <string, object>(e.Data));

            OnNotificationOpenedEvent(args);
        }
Example #3
0
 async void pExec(FirebasePushNotificationResponseEventArgs p)
 {
     if (p.Data.ContainsKey("id_request"))
     {
         var id = int.Parse(p.Data["id_request"].ToString());
         Analytics.TrackEvent("ключ id_request=" + id);
         Analytics.TrackEvent("isCons=" + isCons);
         if (!isCons)
         {
             MessagingCenter.Send <Object, int>(this, "SwitchToApps", id);
         }
         else
         {
             MessagingCenter.Send <Object, int>(this, "SwitchToAppsConst", id);
         }
     }
     else
     {
         Analytics.TrackEvent("ключ id_request не найден");
     }
 }
Example #4
0
        public static async void OnNotificationOpened(object source, FirebasePushNotificationResponseEventArgs e)
        {
            if (e.Identifier != "cancel")
            {
                string title = null;
                string text  = null;

                if (e.Data.ContainsKey("title") && e.Data.ContainsKey("body"))
                {
                    title = e.Data["title"]?.ToString();
                    text  = e.Data["body"]?.ToString();
                }

                if (e.Data.ContainsKey("aps.alert.title") && e.Data.ContainsKey("aps.alert.body"))
                {
                    title = e.Data["aps.alert.title"]?.ToString();
                    text  = e.Data["aps.alert.body"]?.ToString();
                }

                if (!string.IsNullOrEmpty(title) || !string.IsNullOrEmpty(text))
                {
                    e.Data.TryGetValue("documentId", out var id);
                    var documentId = id?.ToString();

                    PushNotificationData = new PushNotificationData
                    {
                        Title      = title,
                        Text       = text,
                        DocumentId = documentId
                    };

                    if (RootPage != null)
                    {
                        await ProcessPushNotification();
                    }
                }
            }
        }