Error setting image URL

Greetings,
We are trying to set the image URL for a new user and are receiving an error

currentUserId cannot be nil.”

I am not sure why the currentUserId is nil since it seemed the device was successfully registered.

        AmityUIKitManager.setup(apiKey: "", region: .US)
        
        client = try! AmityClient(apiKey: "", region: .US)
        AmityUIKitManager.registerDevice(withUserId: userId, displayName: displayName) { [weak self] success, error in
            print("[Sample App] register device with userId '\(userId)' \(success ? "successfully" : "failed")")
            if let error = error {
                print("[Sample App] register device failed \(error.localizedDescription)")
            }
            
            // Build the current user data
            let builder = AmityUserUpdateBuilder()
            builder.setAvatarCustomUrl(imageUrl)
            // Update the current user from the builder
            client?.updateUser(builder) { status, error in
                // Handle the result
            }

you can change from This:

           client?.updateUser(builder) { status, error in
               // Handle the result
           }

To This:

AmityUIKitManager.client?.updateUser(builder) { status, error in
                       // Handle the result
                   }

AmityUIKitManager already initialize client for you so no need to create new client. Also, we are not recommend create multiple clients in one application.

:grinning:

1 Like