async void OnDownloadButtonClicked(object sender, EventArgs e) { string audioUrl = "https://traffic.libsyn.com/secure/draudioarchives/07312019_the_dave_ramsey_show_archive_1.mp3"; //var mainDir = FileSystem.AppDataDirectory; //var destination = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData), "episode.mp3"); //await new System.Net.WebClient().DownloadFileTaskAsync(new Uri(audioUrl), destination); PermissionStatus status = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Storage); await DisplayAlert("Pre - Results", status.ToString(), "OK"); if (status != PermissionStatus.Granted) { if (await CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(Permission.Storage)) { await DisplayAlert("Storing Files", "We need file storage permissions to be able to download episodes for offline playback", "OK"); } var results = await CrossPermissions.Current.RequestPermissionsAsync(Permission.Storage); status = results[Permission.Storage]; } if (status == PermissionStatus.Granted) { downloader.DownloadFile(audioUrl, "episodes"); } else if (status != PermissionStatus.Unknown) { await DisplayAlert("Storage Denied", "You'll need to go to settings and enable file storage", "OK"); } }
private async Task CheckCameraPermissions() { PermissionStatus status = await CrossPermissions.Current.CheckPermissionStatusAsync <CameraPermission>(); if (status != PermissionStatus.Granted) { status = await CrossPermissions.Current.RequestPermissionAsync <CameraPermission>(); } /* * switch (status) * { * case PermissionStatus.Denied: * await DisplayAlert("INFO", "Camera permission is revoked for this app. Please enter OTP manually", "Ok"); * break; * case PermissionStatus.Disabled: * await DisplayAlert("INFO", "Camera permission is not enabled for this app. Please enter OTP manually", "Ok"); * break; * case PermissionStatus.Restricted: * await DisplayAlert("INFO", "Camera permission is restricted for this app. Please enter OTP manually", "Ok"); * break; * case PermissionStatus.Unknown: * await DisplayAlert("INFO", "Camera permission is not exist for this app. Please enter OTP manually", "Ok"); * break; * }*/ Application.Current.Properties["isCameraPermissionAsked"] = status.ToString(); }
private async Task CheckLocationPermissions() { PermissionStatus status = await CrossPermissions.Current.CheckPermissionStatusAsync <LocationWhenInUsePermission>(); if (status != PermissionStatus.Granted) { status = await CrossPermissions.Current.RequestPermissionAsync <LocationWhenInUsePermission>(); } switch (status) { case PermissionStatus.Denied: await DisplayAlert("INFO", "LocationWhenInUse permission is revoked for this app. Please enter OTP manually", "Ok"); break; case PermissionStatus.Disabled: await DisplayAlert("INFO", "LocationWhenInUse permission is not enabled for this app. Please enter OTP manually", "Ok"); break; case PermissionStatus.Restricted: await DisplayAlert("INFO", "LocationWhenInUse permission is restricted for this app. Please enter OTP manually", "Ok"); break; case PermissionStatus.Unknown: await DisplayAlert("INFO", "LocationWhenInUse permission is not exist for this app. Please enter OTP manually", "Ok"); break; } Application.Current.Properties["isLocationPermissionAsked"] = status.ToString(); }
private async void BtnSaveSettings_Clicked(object sender, System.EventArgs e) { PermissionStatus status = await CrossPermissions.Current.CheckPermissionStatusAsync <StoragePermission>(); try { if (status != PermissionStatus.Granted) { await CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(Permission.Storage); status = await CrossPermissions.Current.RequestPermissionAsync <StoragePermission>(); DependencyService.Get <IMessageCenter>().ShortMessage($"Storage Request {status.ToString()}"); DependencyService.Get <IFolderManager>().Settings(); SaveUserSettings(); } else { DependencyService.Get <IFolderManager>().Settings(); SaveUserSettings(); } } catch (Exception ex) { DependencyService.Get <IMessageCenter>().LongMessage(ex.Message); } }
public override string ToString() { return(Status.ToString()); }