Exemplo n.º 1
0
        // Called when a notification is opened.
        // The name of the method can be anything as long as the signature matches.
        // Method must be static or this object should be marked as DontDestroyOnLoad
        private static void HandleNotificationOpened(OSNotificationOpenedResult result)
        {
            OSNotificationPayload       payload        = result.notification.payload;
            Dictionary <string, object> additionalData = payload.additionalData;
            string message  = payload.body;
            string actionID = result.action.actionID;

            if (additionalData != null)
            {
                if (additionalData.ContainsKey("codChamadaVeiculo"))
                {
                    //DateTime dtRecebimento = CrossSettings.Current.Get<DateTime>("dataRecebimentoChamada");
                    if (additionalData.ContainsKey("tempoEsperaAceitacao"))
                    {
                        string tempoEspera = additionalData["tempoEsperaAceitacao"].ToString();
                        CrossSettings.Current.Set("tempoEsperaAceitacao", tempoEspera);
                    }

                    //  var tempoEspera = CrossSettings.Current.Contains

                    var value = additionalData["codChamadaVeiculo"];
                    CrossSettings.Current.Set("ChamadaParaResposta", value.ToString());
                    //NavigationParameters param = new NavigationParameters();
                    //  param.Add("codChamada", value);
                    // if(actionID != null)
                    AppNavigationService.NavigateAsync("//NavigationPage/ResponderChamada", null, true);
                }
            }

            //if (actionID != null)
            //{
            //    if (actionID.Equals("__DEFAULT__"))
            //        AppNavigationService.NavigateAsync("Chamada");

            //    // actionSelected equals the id on the button the user pressed.
            //    // actionSelected will equal "__DEFAULT__" when the notification itself was tapped when buttons were present.
            //    // extraMessage = "Pressed ButtonId: " + actionID;
            //}
        }
Exemplo n.º 2
0
        // Called when your app is in focus and a notificaiton is recieved.
        // The name of the method can be anything as long as the signature matches.
        // Method must be static or this object should be marked as DontDestroyOnLoad
        private static void HandleNotificationReceived(OSNotification notification)
        {
            OSNotificationPayload payload = notification.payload;
            string message = payload.body;
            Dictionary <string, object> additionalData = payload.additionalData;

            if (additionalData != null)
            {
                if (additionalData.ContainsKey("mdn_area"))
                {
                    CrossSettings.Current.Set("atualizarDados", true);
                }
                if (additionalData.ContainsKey("logout"))
                {
                    CrossSettings.Current.Clear();
                    AppNavigationService.NavigateAsync("NavigationPage/Logar");
                }
                if (additionalData.ContainsKey("tempoEsperaAceitacao"))
                {
                    CrossSettings.Current.Set("dataRecebimentoChamada", DateTime.Now);
                }
            }
        }