类型'CKApplicationPermissions'没有成员'PermissionUserDiscoverability'

时间:2017-07-14 10:14:46

标签: permissions cloudkit

我正在使用云套件fetchUserRecordID功能,但需要首先使用以下代码授权requestApplicationPermission访问:

func authoriseICloud(){
    container.requestApplicationPermission(.PermissionUserDiscoverability) { (status, error) in
        guard error == nil else { return }

        if status == CKApplicationPermissionStatus.Granted {
            // yay!
        }
    }
        }

但是我收到以下错误,Type 'CKApplicationPermissions' has no member 'PermissionsUserDiscoverability'.有没有人知道如何成功申请权限?

1 个答案:

答案 0 :(得分:1)

将以下代码段与Swift 3

一起使用
func authoriseICloud(){
    let container = CKContainer.default()
    container.requestApplicationPermission(CKApplicationPermissions.userDiscoverability, completionHandler:{ status, error in
        if status == CKApplicationPermissionStatus.granted {
            // yay!
        }
    })
}

让我知道它是否适合你。