public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
}
I want to call here:
var status = await Permissions.CheckStatusAsync<Permissions.LocationWhenInUse>();
How to do it?
CodePudding user response:
call it in OnAppearing
public override async void OnAppearing()
{
var status = await Permissions.CheckStatusAsync<Permissions.LocationWhenInUse>();
}
CodePudding user response:
If you don't want to call this in the OnAppearing() method and specifically in the contructor, you can do this (watch out for possible thread blocking though):
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
// watch out for possible thread blocking!
Task.Run(async() =>
{
await Permissions.CheckStatusAsync<Permissions.LocationWhenInUse>();
});
}
}