Skip to main content

Documentation Index

Fetch the complete documentation index at: https://learn.social.plus/llms.txt

Use this file to discover all available pages before exploring further.

Retrieve user information using the UserRepository to display profiles, user cards, and social metadata. User objects contain core identity information and provide real-time updates when user data changes.
Live Objects: User data is returned as Live Objects that automatically update when the underlying data changes, keeping your UI synchronized.

Get Single User

Retrieve a specific user by their unique ID:
var token: AmityNotificationToken?

func observeUser() {
    let liveObject = userRepository.getUser("<user-id>")
    token = liveObject.observe { liveObject, error in
        // Handle live object notification
        guard let user = liveObject.object else {
            print("Error: \(String(describing: error))")
            return
        }
        print("User ID: \(user.userId), Display Name: \(user.displayName ?? "Unknown")")
    }
}

Get Multiple Users

Retrieve multiple users efficiently using batch operations:
// Get multiple users by IDs
let userIds = ["user_1", "user_2", "user_3"]

userRepository.getUsers(userIds: userIds) { result in
    switch result {
    case .success(let users):
        users.forEach { user in
            print("\(user.userId): \(user.displayName ?? "Unknown")")
        }
    case .failure(let error):
        print("Error: \(error.localizedDescription)")
    }
}

// Get all users with pagination
let liveCollection = userRepository.getUsers()

liveCollection.observe { [weak self] (collection, error) in
    guard let users = collection.object else { return }
    
    print("Loaded \(users.count) users")
    self?.displayUserList(users)
}

// Load next page
if liveCollection.hasNext {
    liveCollection.nextPage()
}