In the Xamarin.Forms application, I use Application.Current.Properties to save the settings. When my LoginPage downloads, I want to see if the settings exist, but I get an exception, because Application.Current is Null. This is the (sanitized) code that is in LoginPage:
private bool AuthTokenExists()
{
if (Application.Current.Properties.ContainsKey("First") && Application.Current.Properties.ContainsKey("Second"))
{
if (Application.Current.Properties["First"] as string != null &&
Application.Current.Properties["Second"] as string != null)
return true;
}
else
{
return false;
}
}
I read, you cannot call Application.Current.Properties in the App constructor, but this is in ContentPage. Any thoughts why I get an exception? Thanks in advance!
source
share