public async Task ExecuteOpenCameraCommand() { if (IsBusy) { return; } IsBusy = true; try { await Task.Run(async() => { var status = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Camera); var res = App.Current.Resources; if (status != PermissionStatus.Granted) { if (await CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(Permission.Camera)) { await App.Current.MainPage.DisplayAlert((string)res["Permission.Title.Camera"], (string)res["Permission.Message.AppNeedCamera"], (string)res["Permission.Cancel.Okay"]); } var results = await CrossPermissions.Current.RequestPermissionsAsync(Permission.Camera); //Best practice to always check that the key exists if (results.ContainsKey(Permission.Camera)) { status = results[Permission.Camera]; } } //TODO: Double check? if (status == PermissionStatus.Granted) { _openCVService.OpenCamera(); } else if (status != PermissionStatus.Unknown) { await App.Current.MainPage.DisplayAlert((string)res["Permission.Title.Camera"], (string)res["Permission.Message.AppNotPermitted"], (string)res["Permission.Cancel.Okay"]); } }); } catch (Exception) { var res = App.Current.Resources; await App.Current.MainPage.DisplayAlert((string)res["Permission.Title.Camera"], (string)res["Permission.Message.AppNotPermitted"], (string)res["Permission.Cancel.Okay"]); } IsBusy = false; }