Providing User Information

User and group names and avatars are managed by your app. The SDK needs to be able to obtain them for display in the chat UI, and does so by calling a ProfileProvider delegate that you must implement:

/// Provide user information via this protocol. 
public protocol ProfileProvider {

    /// Call back with name of user for the given user id.
    func fetchName(user userId: String, callback: @escaping (String?) -> Void)

    /// Call back with avatar image of user for the given user id.
    func fetchAvatar(user userId: String, preferredSize: Int, callback: @escaping (UIImage?) -> Void)

    /// Call back with name of group chat for the given chat id.
    func fetchName(group chatId: String, callback: @escaping (String?) -> Void)

    /// Call back with avatar image of group chat for the given chat id.
    func fetchAvatar(group chatId: String, preferredSize: Int, callback: @escaping (UIImage?) -> Void)
}

Implement this protocol such that it calls the callback methods with the results for each call (including nil for when no avatar image exists). Then, set an instance of your implementation as the delegate for the Profiles singleton as follows:

Profiles.shared.delegate = myProfileProvider 

The delegate methods are always called on the main queue. If your implementation takes time to obtain the results, you should do the processing on a background queue and call the callback from there once ready. The objects returned by the callback will be used on the main queue.