如果在swift中拒绝访问照片库的权限,如何直接进入设置

时间:2018-04-25 10:39:49

标签: ios iphone swift3

class func checkPhotoLibraryPermission() {
        // TODO: @Umer Complete this process as discussed
        let photoAuthorizationStatus = PHPhotoLibrary.authorizationStatus()
        switch photoAuthorizationStatus {
        case .authorized:
            print("Access is granted by user")
        case .notDetermined:
            PHPhotoLibrary.requestAuthorization({
                (newStatus) in
                print("status is \(newStatus)")
                if newStatus ==  PHAuthorizationStatus.authorized {
                    /* do stuff here */
                    print("success")
                }
                else {
                }
            })
            print("It is not determined until now")
        case .restricted:
            print("User do not have access to photo album.")
        case .denied:
            print("User has denied the permission.")
        }
    }

万一.denied     如果我们第一次访问照片库,则会向用户询问访问权限,如果用户不允许,则下次用户尝试访问照片库时,会直接进入用户可以手动设置权限的设置。

0 个答案:

没有答案