iOSアルバム権限、カメラ権限、マイク権限

2088 ワード

アルバムのアクセス権
iOS 8の後にPhotoKitが加わり、使用には
 #import  
が必要です
  • 権限タイプ

    typedef NS_ENUM(NSInteger, PHAuthorizationStatus) {

    PHAuthorizationStatusNotDetermined = 0, //

    PHAuthorizationStatusRestricted, // ,

    PHAuthorizationStatusDenied, // ,

    PHAuthorizationStatusAuthorized//
    }

  • 権限検出

    PHAuthorizationStatus photoAuthStatus = [PHPhotoLibrary authorizationStatus];

    if (photoAuthStatus == PHAuthorizationStatusNotDetermined) {//

    }else if(photoAuthStatus == PHAuthorizationStatusRestricted || photoAuthStatus == PHAuthorizationStatusDenied) {//

    }else{//

    }

  • 要求認可

    [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
    if (status == PHAuthorizationStatusAuthorized) {
    //
    }else {
    //
    }
  • カメラ&マイク権限
    まず
    #import  

    カメラ対応AVMediaTypeVideo
    マイク対応AVMediaTypeAudio
  • 権限タイプ

    typedef NS_ENUM(NSInteger, AVAuthorizationStatus) {

    AVAuthorizationStatusNotDetermined = 0,//

    AVAuthorizationStatusRestricted,// ,

    AVAuthorizationStatusDenied,// ,

    AVAuthorizationStatusAuthorized//
    }

  • 権限検出

    AVAuthorizationStatus videoAuthStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];

    if (videoAuthStatus == AVAuthorizationStatusNotDetermined) {//

    }else if(videoAuthStatus == AVAuthorizationStatusRestricted || videoAuthStatus == AVAuthorizationStatusDenied) {//

    }else{//

    }

  • 要求認可

    [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) {
    if (granted){//
          }else {//       
    
          }
    
    }];