/// <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)));
        }
Exemplo n.º 2
0
        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
        }
Exemplo n.º 3
0
 static PermissionStatus GetPhotoPermissionStatus(PHAccessLevel level)
 => Convert(CheckOSVersionForPhotos()
                         ? PHPhotoLibrary.GetAuthorizationStatus(level)
                         : PHPhotoLibrary.AuthorizationStatus);