实用程序.m
+(AVAuthorizationStatus)getAuthorizationStatus {
NSString *mediaType = AVMediaTypeAudio;
__block AVAuthorizationStatus AuthStatus = [AVCaptureDevice authorizationStatusForMediaType:mediaType];
if(AuthStatus == AVAuthorizationStatusNotDetermined) {
[AVCaptureDevice requestAccessForMediaType:mediaType completionHandler:^(BOOL granted) {
AuthStatus = [AVCaptureDevice authorizationStatusForMediaType:mediaType];
}];
}
NSLog(@"%d",AuthStatus);
return AuthStatus;
}
+(ALAuthorizationStatus)getALAssetAuthorizationStatus {
ALAssetsLibrary *aLib = [[ALAssetsLibrary alloc]init];
ALAuthorizationStatus alAuthStatus;
[aLib enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:nil failureBlock:nil];
alAuthStatus = [ALAssetsLibrary authorizationStatus];
NSLog(@"Status=>%d", [ALAssetsLibrary authorizationStatus]);
return alAuthStatus;
}
在我的实用程序类中,我编写了这两种方法,目的只是为了告诉授权状态是什么。
如果用户已经allowed
或denied
权限,这些方法将正常工作,但这些方法第一次要求用户权限并且授权状态为not determined
. 如果用户allow
或deny
我第一次没有获得更新的授权状态。如何处理?