Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Application.Current.Properties is Empty when app close

$
0
0

I'm using Xamarin Forms I have two method to authenticate user :

1 : the user enter username and password

2 : the user can authenticate with their Office 365 account .

for the first method when the user enter his username and password and check if username and password existe ...
i do this :

                        var app = Application.Current as App;
            app.Properties["logged"] = "true";

when closing the app and open it

App.cs

        if (this.Properties.ContainsKey("logged") && this.Properties["logged"].ToString() == "true")
        {
            MainPage = new NavigationPage(new MasterMenuPage());
        }
        else
        {
            if (this.Properties.ContainsKey("currentConfig"))
            {
                MainPage = new NavigationPage(new AuthentificationPage());
            }
            else
            {
                MainPage = new NavigationPage(new ChoixEcole());
            }
        }

protected override void OnStart()
{
// Handle when your app starts
Console.WriteLine("OnStart Method logged 1--> " + Application.Current.Properties.ContainsKey("logged"));
Console.WriteLine("OnStart Method logged 2--> " + this.Properties["logged"].ToString());
} 

Console :

OnStart Method logged 1--> True
OnStart Method logged 2--> true

Automatically the main page is shown

same thing for Office but i always go back to the Authentification Page and Application.Current.Properties.ContainsKey("logged"). is false

 var app = Application.Current as App;
 app.Properties["logged"] = "true";

Console :

OnStart Method logged 1--> False

it's the same logic buy i can not understand why a lose information when i login with office account.


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>