Hello @Jassim Al Rahma ,
You cannot use await
in App()
, because the await
operator can only be used within an async method, App()
is a constructor, async constructors are not allowed. There is a similar question - Run await inside constructor - Microsoft Q&A, you could check it.
For more details, you can refer to Compiler Error CS4033 | Microsoft Learn
and Asynchronous programming in C# | Microsoft Learn.
In addition, you are requesting the Android permissions, you can call it in the OnAppearing
method of AppShell
or other Pages.
protected override async void OnAppearing()
{
base.OnAppearing();
PermissionStatus status = await Permissions.RequestAsync<Permissions.ContactsRead>();
if (status == PermissionStatus.Granted){
// do something
}else{
// do something else
}
}
Best Regards,
Wenyan Zhang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.