void CheckPhotoLibraryAutorizationStatus(PHAuthorizationStatus authorizationStatus) { switch (authorizationStatus) { case PHAuthorizationStatus.NotDetermined: PHPhotoLibrary.RequestAuthorization(CheckPhotoLibraryAutorizationStatus); break; case PHAuthorizationStatus.Restricted: InvokeOnMainThread(() => ShowMessage("Acceso Restringido", "", NavigationController)); break; case PHAuthorizationStatus.Denied: InvokeOnMainThread(() => ShowMessage("Acceso Denegado", "", NavigationController)); break; case PHAuthorizationStatus.Authorized: InvokeOnMainThread(() => { var imagePickerController = new UIImagePickerController { SourceType = UIImagePickerControllerSourceType.PhotoLibrary, Delegate = this }; PresentViewController(imagePickerController, true, null); }); break; default: break; } }
/// Reload collection view layout/data based on authorization status of photo library private void ReloadData(PHAuthorizationStatus status) { switch (status) { case PHAuthorizationStatus.Authorized: _collectionViewDataSource.AssetsModel.UpdateFetchResult(AssetsFetchResultBlock?.Invoke()); _collectionViewDataSource.UpdateLayoutModel(new LayoutModel(LayoutConfiguration, (int)_collectionViewDataSource.AssetsModel.FetchResult.Count)); break; case PHAuthorizationStatus.Restricted: case PHAuthorizationStatus.Denied: var view = _overlayView ?? DataSource?.ImagePicker(status); if (view != null && !view.Superview.Equals(CollectionView)) { CollectionView.BackgroundView = view; _overlayView = view; } break; case PHAuthorizationStatus.NotDetermined: PHPhotoLibrary.RequestAuthorization(authorizationStatus => { DispatchQueue.MainQueue.DispatchAsync(() => { ReloadData(authorizationStatus); }); }); break; } }
public void Execute() { #if !UNITY_EDITOR PHAuthorizationStatus phstatus = (PHAuthorizationStatus)Enum.ToObject( typeof(PHAuthorizationStatus), UnityiOS.HasCameraRollPermission()); UnityiOS.PlaySystemShutterSound(); if (phstatus == PHAuthorizationStatus.Authorized) { StartCoroutine(_CaptureScreenShot()); } else { } #endif }
public static void RequestPermissions() { AVAuthorizationStatus avstatus = HasCameraPermission(); PHAuthorizationStatus phstatus = HasCameraRollPermission(); //アクセス許可のリクエストを出していない場合はリクエストを送る if (avstatus == AVAuthorizationStatus.NotDetermined) { _RequestCameraPermission(); } if (phstatus == PHAuthorizationStatus.NotDetermined) { _RequestCameraRollPermission(); } }
public void Execute() { #if !UNITY_EDITOR PHAuthorizationStatus phstatus = (PHAuthorizationStatus)Enum.ToObject( typeof(PHAuthorizationStatus), UnityiOS.HasCameraRollPermission()); UnityiOS.PlaySystemShutterSound(); if (phstatus == PHAuthorizationStatus.Authorized) { Handheld.SetActivityIndicatorStyle(UnityEngine.iOS.ActivityIndicatorStyle.Gray); Handheld.StartActivityIndicator(); StartCoroutine(_CaptureScreenShot()); } else { OnFailCapture.Invoke(); } #endif }
void CheckPhotoLibraryAuthorizationStatus(PHAuthorizationStatus authorizationStatus) { switch (authorizationStatus) { case PHAuthorizationStatus.NotDetermined: //permiso para abrir la camara PHPhotoLibrary.RequestAuthorization(CheckPhotoLibraryAuthorizationStatus); break; case PHAuthorizationStatus.Restricted: //mensaje de restringido InvokeOnMainThread(() => { ShowMessage("Recurso no disponible", "La app no tiene permiso para acceder al recurso", NavigationController); }); break; case PHAuthorizationStatus.Denied: //el usuario denego el recurso InvokeOnMainThread(() => { ShowMessage("Recurso no disponible", "El usuario denego el recurso", NavigationController); }); break; case PHAuthorizationStatus.Authorized: //Abrir galeria InvokeOnMainThread(() => { var imagePickerController = new UIImagePickerController { SourceType = UIImagePickerControllerSourceType.PhotoLibrary, Delegate = this }; PresentViewController(imagePickerController, true, null); }); break; default: break; } }
private void GetFromMemory() { PHAuthorizationStatus photos = PHPhotoLibrary.AuthorizationStatus; if (photos == PHAuthorizationStatus.Authorized) { GetPhoto(); return; } PHPhotoLibrary.RequestAuthorization(status => { if (status == PHAuthorizationStatus.Authorized) { GetPhoto(); } }); }
void CheckPhotoLibraryAuthorizationStatus(PHAuthorizationStatus authorizationStatus) { switch (authorizationStatus) { case PHAuthorizationStatus.NotDetermined: //TODO: Ask for permission to open galerry PHPhotoLibrary.RequestAuthorization(CheckPhotoLibraryAuthorizationStatus); break; case PHAuthorizationStatus.Restricted: //TODO: Display a message of restricted InvokeOnMainThread(() => { ShowMessage("Resource not available", "The resource is not available due it's restricted to use", NavigationController); }); break; case PHAuthorizationStatus.Denied: //TODO: Show a message that user denied the authorization InvokeOnMainThread(() => { ShowMessage("Resource not available", "The resource is not available due it was denied by the user.", NavigationController); }); break; case PHAuthorizationStatus.Authorized: //TODO: Open Gallery InvokeOnMainThread(() => { var imagePickerController = new UIImagePickerController { SourceType = UIImagePickerControllerSourceType.PhotoLibrary, Delegate = this }; PresentViewController(imagePickerController, true, null); }); break; default: break; } }
void CheckPhotoLibraryAuthorizationStatus(PHAuthorizationStatus authorizationStatus) { switch (authorizationStatus) { case PHAuthorizationStatus.NotDetermined: // Vamos a pedir permiso para acceder a la galeria //InvokeOnMainThread(() => { PHPhotoLibrary.RequestAuthorization(CheckPhotoLibraryAuthorizationStatus); //}); break; case PHAuthorizationStatus.Restricted: InvokeOnMainThread(() => { showMessage("No disponible", "El recurso no esta disponible, esta restringido", NavigationController); }); //Mostrar mensaje de restringido break; case PHAuthorizationStatus.Denied: InvokeOnMainThread(() => { showMessage("No disponible", "El recurso no esta disponible, esta denegado por ti", NavigationController); }); //Mostrar un mensaje diciendo que el usuario denego break; case PHAuthorizationStatus.Authorized: InvokeOnMainThread(() => { var imagePickerController = new UIImagePickerController { SourceType = UIImagePickerControllerSourceType.PhotoLibrary, Delegate = this }; PresentViewController(imagePickerController, true, null); }); break; default: break; } }
public static AuthorizationState ToShared(this PHAuthorizationStatus status) { var state = AuthorizationState.NotDetermined; switch (status) { case PHAuthorizationStatus.NotDetermined: break; case PHAuthorizationStatus.Authorized: state = AuthorizationState.Authorized; break; case PHAuthorizationStatus.Restricted: case PHAuthorizationStatus.Denied: state = AuthorizationState.Denied; break; } return(state); }
public override UIView ImagePicker(PHAuthorizationStatus status) { var infoLabel = new UILabel(CGRect.Empty) { BackgroundColor = UIColor.Green, TextAlignment = UITextAlignment.Center, Lines = 0 }; switch (status) { case PHAuthorizationStatus.Restricted: infoLabel.Text = "Access is restricted\n\nPlease open Settings app and update privacy settings."; break; case PHAuthorizationStatus.Denied: infoLabel.Text = "Access is denied by user\n\nPlease open Settings app and update privacy settings."; break; } return(infoLabel); }
void CheckPhotoLibraryAuthorizationStatus(PHAuthorizationStatus authorizationStatus) { switch (authorizationStatus) { case PHAuthorizationStatus.NotDetermined: //Pedir permiso PHPhotoLibrary.RequestAuthorization(CheckPhotoLibraryAuthorizationStatus); break; case PHAuthorizationStatus.Restricted: InvokeOnMainThread(() => { ShowMessage("Its is resticted", "", NavigationController); }); break; case PHAuthorizationStatus.Denied: InvokeOnMainThread(() => { ShowMessage("It is denied", "", NavigationController); }); break; case PHAuthorizationStatus.Authorized: //Open photo library InvokeOnMainThread(() => { var imagePicker = new UIImagePickerController { SourceType = UIImagePickerControllerSourceType.PhotoLibrary, Delegate = this }; PresentViewController(imagePicker, true, null); }); break; default: break; } }
void CheckPhotoLibraryAutorizationStatus(PHAuthorizationStatus authorizationStatus) { switch (authorizationStatus) { case PHAuthorizationStatus.NotDetermined: //TODO: VAMOS A PEDIR EL PERMISO PARA ACCEDER LA GALERIA PHPhotoLibrary.RequestAuthorization(CheckPhotoLibraryAutorizationStatus); break; case PHAuthorizationStatus.Restricted: //TODO: MOSTRAR UN MSG DICIENDO QUE ESTA RESTRINGIDO InvokeOnMainThread(() => ShowMessage("Acceso a Fotos Restringido", "Chale weee no que si la querias ver krnal??? Te quieres morir??", NavigationController)); break; case PHAuthorizationStatus.Denied: //TODO: MOSTRAR UN MSG DICIENDO QUE ESTA DENEGADO InvokeOnMainThread(() => ShowMessage("Acceso a Fotos Denegado", "Por que no muestras los packs??? Te quieres morir??", NavigationController)); break; case PHAuthorizationStatus.Authorized: //TODO: VAMOS A ABRIR LA GALERIA InvokeOnMainThread(() => { var imagePickerController = new UIImagePickerController { SourceType = UIImagePickerControllerSourceType.PhotoLibrary, Delegate = this }; PresentViewController(imagePickerController, true, null); }); break; default: break; } }
void CheckPhotoLibraryAuthorizationsStatus(PHAuthorizationStatus authorizationStatus) { switch (authorizationStatus) { case PHAuthorizationStatus.NotDetermined: // TODO: Pedir permiso para acceder PHPhotoLibrary.RequestAuthorization(CheckPhotoLibraryAuthorizationsStatus); break; case PHAuthorizationStatus.Restricted: // TODO: Mostrar un mensaje diciendo que está restringido InvokeOnMainThread(() => { ShowMessage("Error", "El recuerso no esa dispiie", NavigationController); }); break; case PHAuthorizationStatus.Denied: // TODO: Mostrar un mensaje diciendo que el usuario denego InvokeOnMainThread(() => { ShowMessage("Error", "El recuerso no esta disponible", NavigationController); }); break; case PHAuthorizationStatus.Authorized: InvokeOnMainThread(() => { var imagePickerController = new UIImagePickerController { SourceType = UIImagePickerControllerSourceType.PhotoLibrary, Delegate = this }; PresentViewController(imagePickerController, true, null); }); break; default: break; } }
private void CheckPhotoLibraryAuthorizationStatus(PHAuthorizationStatus authorizationStatus) { switch (authorizationStatus) { case PHAuthorizationStatus.NotDetermined: // Vamos a pedir permiso para acceder a la galeria PHPhotoLibrary.RequestAuthorization(CheckPhotoLibraryAuthorizationStatus); break; case PHAuthorizationStatus.Restricted: InvokeOnMainThread(() => { showMessage("Not Available", "The resource is not available, it is restricted", NavigationController); }); //Mostrar mensaje de restringido break; case PHAuthorizationStatus.Denied: InvokeOnMainThread(() => { showMessage("Not Available", "The resource is not available, it is denied by you", NavigationController); }); //Mostrar un mensaje diciendo que el usuario denego break; case PHAuthorizationStatus.Authorized: InvokeOnMainThread(() => { var imagePickerController = new UIImagePickerController { SourceType = UIImagePickerControllerSourceType.PhotoLibrary, Delegate = this }; PresentViewController(imagePickerController, true, null); }); break; default: break; } }
void CheckLibraryAuthorizationStatus(PHAuthorizationStatus authorizationStatus) { switch (authorizationStatus) { case PHAuthorizationStatus.NotDetermined: //TODO: Vamos a pedir el permiso para acceder PHPhotoLibrary.RequestAuthorization(CheckLibraryAuthorizationStatus); break; case PHAuthorizationStatus.Restricted: //TODO: Mostrar un mensaje diciendo que esta restringido InvokeOnMainThread(() => ShowMessage("Error", "El permiso esta restringido.", NavigationController)); break; case PHAuthorizationStatus.Denied: //TODO: El usuario denego el permiso. InvokeOnMainThread(() => ShowMessage("Error", "El permiso fue denegado.", NavigationController)); break; case PHAuthorizationStatus.Authorized: //TODO: Abrir la galeria InvokeOnMainThread(() => { var imagePickerController = new UIImagePickerController { SourceType = UIImagePickerControllerSourceType.PhotoLibrary, Delegate = this }; PresentViewController(imagePickerController, true, null); }); break; default: break; } }
void CheckPhotoLibraryAuthorizationStatus(PHAuthorizationStatus authorizationStatus) { switch (authorizationStatus) { case PHAuthorizationStatus.NotDetermined: // Vamos a pedir el permiso para acceder a la galería. //Recursivo, el parámetro es la función misma. Aquí ya entraría en los siguientes opciones //que lo haya denegado o autorizado, dependiendo de lo que haga el usuario al realizarse //la petición. //Solicitud de los permisos y su callback. PHPhotoLibrary.RequestAuthorization(CheckPhotoLibraryAuthorizationStatus); break; case PHAuthorizationStatus.Restricted: // Mostrar un mensaje diciendo que está restringido. InvokeOnMainThread(() => { ShowMessage(title: "Resource not available.", message: "The resource is not available due its restricted use.", fromViewController: NavigationController); }); break; case PHAuthorizationStatus.Denied: // Mostrar un mensaje diciendo que el usuario denegó el permiso. InvokeOnMainThread(() => { ShowMessage(title: "Resource not available.", message: "The resource is not available due it was denied by you.", fromViewController: NavigationController); }); break; case PHAuthorizationStatus.Authorized: // Vamos a abrir la galería. //Pasarse al hilo principal, ya que esta parte se ejecuta en un método asíncrono. InvokeOnMainThread(() => { //Inicializar una variable para abrir la librería de imágenes. var imagePickerController = new UIImagePickerController { SourceType = UIImagePickerControllerSourceType.PhotoLibrary, //Se asigna "this" porque aquí se está implementando el delegado. Delegate = this }; //Se presenta en pantalla la librería de imágenes. PresentViewController(imagePickerController, true, null); }); break; default: break; } }
private static void OnPhotoLibraryRequested(PHAuthorizationStatus status) { RaiseAuthorizationRequested(AuthorizationType.PhotoLibrary, status.ToShared()); }
PermissionStatus Convert(PHAuthorizationStatus status) => status switch {
/// <summary> /// Asks for a view that is placed as overlay view with permissions info /// when user did not grant or has restricted access to photo library. /// </summary> public abstract UIView ImagePicker(PHAuthorizationStatus status);