#import <AssetsLibrary/AssetsLibrary.h>
#import <AVFoundation/AVFoundation.h>
#import <AddressBook/AddressBook.h>
#import <CoreLocation/CoreLocation.h>
#import <UIKit/UIKit.h>
+ (BOOL) isPhotosAuthorized;
{
ALAuthorizationStatus author = [ALAssetsLibrary authorizationStatus];
if (author == ALAuthorizationStatusDenied)
{
return NO;
}
return YES;
}
+ (BOOL) isCameraAuthorized
{
AVAuthorizationStatus avStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
BOOL isHaveCamera = (avStatus == AVAuthorizationStatusAuthorized || avStatus == AVAuthorizationStatusNotDetermined);
if (!isHaveCamera)
{
return NO;
}
return YES;
}
+ (BOOL) isMicroPhoneAuthorized
{
__block BOOL bCanRecord = YES;
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
if ([audioSession respondsToSelector:@selector(requestRecordPermission:)])
{
[audioSession performSelector:@selector(requestRecordPermission:) withObject:^(BOOL granted) {
bCanRecord = granted;
}];
}
return bCanRecord;
}
+ (BOOL) isNotificationAuthorized
{
BOOL isAllowNotifi = NO;
UIUserNotificationSettings *setting = [[UIApplication sharedApplication] currentUserNotificationSettings];
if (UIUserNotificationTypeNone != setting.types)
{
isAllowNotifi = YES;
}
return isAllowNotifi;
}
+ (BOOL)isLocatonAuthorized
{
if (![CLLocationManager locationServicesEnabled])
{
return NO;
}
CLAuthorizationStatus status = [CLLocationManager authorizationStatus];
if (status == kCLAuthorizationStatusAuthorizedWhenInUse || status == kCLAuthorizationStatusAuthorizedAlways )
{
return YES;
}
return NO;
}
+ (BOOL) isContactsAuthorized
{
if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusDenied || ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusRestricted)
{
return NO;
}
return YES;
}
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者