Exemple #1
0
        public App()
        {
            InitializeComponent();

            Current = this;


            LarguraTela = Resolver.Resolve <IDevice>().Display.Width;
            AlturaTela  = Resolver.Resolve <IDevice>().Display.Height;

            if (Logado)
            {
                MainPage = new NavigationPage(new Views.Home());
                GravaToken();
            }
            else
            {
                MainPage = new Views.Login();
            }

            MessagingCenter.Subscribe <object>(this, "Logado", (sender) =>
            {
                MainPage = new NavigationPage(new Views.Home());
                PushNotification.Plugin.CrossPushNotification.Current.Register();
            });

            MessagingCenter.Subscribe <object>(this, "Logoff", async(sender) =>
            {
                using (APIHelper API = new APIHelper())
                {
                    try
                    {
                        await API.POST("api/usuario/logoff", new { });
                    }
                    catch (Exception)
                    {
                    }
                    UsuarioLogado          = null; //Limpa dados
                    API.HeadersAllRequests = new Dictionary <string, string>();
                }

                MainPage = new Views.Login();
            });

            MessagingCenter.Subscribe <object, String>(this, "PushTokenAtualizado", (sender, token) =>
            {
                if (PushToken != token)
                {
                    PushTokenGravado = false;
                    PushToken        = token;
                    GravaToken();
                }
            });
        }
Exemple #2
0
        public App()
        {
            InitializeComponent();

            Current = this;


            LarguraTela = Resolver.Resolve <IDevice>().Display.Width;
            AlturaTela  = Resolver.Resolve <IDevice>().Display.Height;

            if (Logado)
            {
                MainPage = new Views.Home();
            }
            else
            {
                MainPage = new Views.Login();
            }

            MessagingCenter.Subscribe <object>(this, "Logado", (sender) =>
            {
                MainPage = new Views.Home();
            });

            //MessagingCenter.Subscribe<object>(this, "Logoff", async (sender) => {
            //    using (APIHelper API = new APIHelper())
            //    {
            //        try
            //        {
            //            await API.POST("api/usuario/logoff", new { });
            //        }
            //        catch (Exception)
            //        {
            //        }
            //        UsuarioLogado = null; //Limpa dados
            //        API.HeadersAllRequests = new Dictionary<string, string>();
            //    }

            //    MainPage = new Views.Login();
            //});
        }