When I upload all contact and ask for any common friends, it just return null. But I have common friends who use digit and if there is no friends, it's just return
[ ]
But now it's return nil. ( Here's the output of below code )
Total contacts: 10, uploaded successfully: 10
Friends: Digits ID: nil
how can I get digit users ? what's the error in my code ( previously this successfully returned common digit users )
In viewDidLoad()
let digits = Digits.sharedInstance().session()
self.uploadDigitsContacts(digits!)
And then the functions :-
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)")
}
}
}
Found the solution !!! When you use the same simulator for upload contacts by using different numbers this error occurs. So try to delete all contacts from that Phone number by using :-
Then log out from that device :-
Then again sign in to Digit and upload contacts again, and request for any friends who are using the app. Don't forget to remove deleteAllUploadedContactWithCompletion when sign in again to digit.