Skip to content

Instantly share code, notes, and snippets.

@rafaelcrz
Forked from insidegui/DiscoverUserIdentity.swift
Created November 30, 2022 22:39
Show Gist options
  • Save rafaelcrz/13d232d75a8e37e824e06a083327f35d to your computer and use it in GitHub Desktop.
Save rafaelcrz/13d232d75a8e37e824e06a083327f35d to your computer and use it in GitHub Desktop.
CKContainer.default().requestApplicationPermission(.userDiscoverability) { status, error in
guard status == .granted, error == nil else {
// error handling voodoo
return
}
CKContainer.default().discoverUserIdentity(withUserRecordID: recordID) { identity, error in
guard let components = identity?.nameComponents, error == nil else {
// more error handling magic
return
}
DispatchQueue.main.async {
let fullName = PersonNameComponentsFormatter().string(from: components)
print("The user's full name is \(fullName)")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment