/// <summary>Checks the status of <see cref="SaveMediaPermission"/>.</summary> /// <returns>The current status of the permission.</returns> public override Task <PermissionStatus> CheckStatusAsync() { EnsureDeclared(); var auth = MediaGallery.HasOSVersion(14) ? PHPhotoLibrary.GetAuthorizationStatus(PHAccessLevel.AddOnly) : PHPhotoLibrary.AuthorizationStatus; return(Task.FromResult(Convert(auth))); }
public void Setup() { TestRuntime.AssertSystemVersion(PlatformName.iOS, 8, 0, throwIfOtherPlatform: false); #if HAS_ASSETSLIBRARY if (ALAssetsLibrary.AuthorizationStatus != ALAuthorizationStatus.Authorized) { Assert.Inconclusive("Requires access to the photo library"); } #elif __MACCATALYST__ TestRuntime.AssertSystemVersion(PlatformName.MacCatalyst, 14, 0, throwIfOtherPlatform: false); if (PHPhotoLibrary.GetAuthorizationStatus(PHAccessLevel.ReadWrite) != PHAuthorizationStatus.Authorized) { Assert.Inconclusive("Requires access to the photo library"); } #else #error Add authorization check for the platform #endif }
static PermissionStatus GetPhotoPermissionStatus(PHAccessLevel level) => Convert(CheckOSVersionForPhotos() ? PHPhotoLibrary.GetAuthorizationStatus(level) : PHPhotoLibrary.AuthorizationStatus);