How may I check if my app has access to phone gallery

前端 未结 4 1421
伪装坚强ぢ
伪装坚强ぢ 2021-02-05 10:58

I have an app in which I take a picture with the camera and store that image into the native gallery. But if the app doesn\'t have permission for that, I want the user to know t

4条回答
  •  情话喂你
    2021-02-05 11:56

    Swift 3

    import photos
    
    PHPhotoLibrary.requestAuthorization { status in
         switch status {
         case .authorized:
              self.processSnapShotPhotos()
         case .restricted:
              print("handle restricted")
         case .denied:
              print("handle denied")     
         default:
           // place for .notDetermined - in this callback status is already determined so should never get here
                break
         }
    }
    

提交回复
热议问题