Пример #1
0
        void FirePhotoPermissionCompletionHandler()
        {
            ALAuthorizationStatus status = ALAssetsLibrary.AuthorizationStatus;

            if (_photoPermissionCompletionHandler != null)
            {
                ClusterDialogResult userDialogResult   = ClusterDialogResult.Granted;
                ClusterDialogResult systemDialogResult = ClusterDialogResult.Granted;
                if (status == ALAuthorizationStatus.NotDetermined)
                {
                    userDialogResult   = ClusterDialogResult.Denied;
                    systemDialogResult = ClusterDialogResult.NoActionTaken;
                }
                else if (status == ALAuthorizationStatus.Authorized)
                {
                    userDialogResult   = ClusterDialogResult.Granted;
                    systemDialogResult = ClusterDialogResult.Granted;
                }
                else if (status == ALAuthorizationStatus.Denied)
                {
                    userDialogResult   = ClusterDialogResult.Granted;
                    systemDialogResult = ClusterDialogResult.Denied;
                }
                else if (status == ALAuthorizationStatus.Restricted)
                {
                    userDialogResult   = ClusterDialogResult.Granted;
                    systemDialogResult = ClusterDialogResult.ParentallyRestricted;
                }
                _photoPermissionCompletionHandler((status == ALAuthorizationStatus.Authorized),
                                                  userDialogResult,
                                                  systemDialogResult);
                _photoPermissionCompletionHandler = null;
            }
        }
Пример #2
0
        public void ShowPhotoPermissionsWithTitle(string requestTitle, string message, string denyButtonTitle, string grantButtonTitle, ClusterPrePermissionCompletionHandler completionHandler)
        {
            if (requestTitle.Length == 0)
            {
                requestTitle = @"Access Photos?";
            }
            denyButtonTitle  = GetTitleForType(ClusterTitleType.Deny, denyButtonTitle);
            grantButtonTitle = GetTitleForType(ClusterTitleType.Request, grantButtonTitle);

            ALAuthorizationStatus status = ALAssetsLibrary.AuthorizationStatus;

            if (status == ALAuthorizationStatus.NotDetermined)
            {
                _photoPermissionCompletionHandler = completionHandler;
                _prePhotoPermissionAlertView      = new UIAlertView(requestTitle, message, new AlertViewDelegate(this), denyButtonTitle, grantButtonTitle);
                _prePhotoPermissionAlertView.Show();
            }
            else
            {
                if (completionHandler != null)
                {
                    completionHandler((status == ALAuthorizationStatus.Authorized),
                                      ClusterDialogResult.NoActionTaken,
                                      ClusterDialogResult.NoActionTaken);
                }
            }
        }