In a Xamarin.Forms app I'm using Application.Current.Properties to save settings. When my LoginPage loads I want to see if settings exist but I'm getting an exception saying Application.Current is Null. This is the (sanitized) code, which is in the LoginPage:
private bool AuthTokenExists()
{
// The following line throws the exception
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've read you can't call Application.Current.Properties in the App constructor, but this is in a ContentPage. Any thoughts why I'm getting the exception? Thanks in advance!
CurrentandPropertiesis null. It might help.