当我上传所有联系人并询问任何共同的朋友时,它只是返回 null。但是我有共同的朋友使用数字,如果没有朋友,它只是返回
[ ]
但现在它的回报为零。(这是下面代码的输出)
联系人总数:10,上传成功:10
朋友:数字ID:无
如何获得数字用户?我的代码有什么错误(以前成功返回了普通数字用户)
在 viewDidLoad()
let digits = Digits.sharedInstance().session()
self.uploadDigitsContacts(digits!)
然后是功能:-
private func uploadDigitsContacts(session: DGTSession) {
let digitsContacts = DGTContacts(userSession: session)
digitsContacts.startContactsUploadWithCompletion { result, error in
if result != nil {
// The result object tells you how many of the contacts were uploaded.
print("Total contacts: \(result.totalContacts), uploaded successfully: \(result.numberOfUploadedContacts)")
self.findDigitsFriends(session)
}
}
}
private func findDigitsFriends(session: DGTSession) {
let digitsSession = Digits.sharedInstance().session()
let digitsContacts = DGTContacts(userSession: digitsSession)
// looking up friends happens in batches. Pass nil as cursor to get the first batch.
digitsContacts.lookupContactMatchesWithCursor(nil) { (matches, nextCursor, error) -> Void in
// If nextCursor is not nil, you can continue to call lookupContactMatchesWithCursor: to retrieve even more friends.
// Matches contain instances of DGTUser. Use DGTUser's userId to lookup users in your own database.
print("Friends:")
print("Digits ID: \(matches)")
for digitsUser in matches {
print("Digits ID: \(digitsUser.userID)")
}
}
}