// Getting app users (contacts who are already using the app)
func displayAppUsers() async {
do {
let appUsers = try await ContactsService.shared.getContactsUsingApp(limit: 20)
for user in appUsers {
// Access local contact info if available
if let localContact = user.contact {
print("Local contact: \(localContact.displayName ?? "Unknown")")
// Get their local phone numbers
for phone in localContact.phoneNumbers {
print("Phone: \(phone.value ?? "None")")
}
}
// Access server-side user profile info
let canonicalUser = user.canonicalContact
print("User profile: \(canonicalUser.fullName)")
print("Organization user ID: \(canonicalUser.organizationUserId)")
// You can use the organization user ID for social features
await followUser(userId: canonicalUser.organizationUserId)
}
} catch {
print("Error getting app users: \(error.localizedDescription)")
}
}
// Follow a user using their organization user ID
func followUser(userId: String) async {
do {
let result = try await ContactsService.shared.socialService.followUser(
userId: userId
)
if let success = result.success, success {
print("Successfully followed user")
}
} catch {
print("Error following user: \(error.localizedDescription)")
}
}