# Error setting image URL

**URL:** https://forum.social.plus/t/error-setting-image-url/543
**Category:** iOS
**Created:** [October 7, 2022, 11:07am UTC](https://forum.social.plus/t/error-setting-image-url/543 "2022-10-07T11:07:37Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![pdxchance](https://avatars.discourse-cdn.com/v4/letter/p/db5fbb/32.png) [@pdxchance](https://forum.social.plus/u/pdxchance)
#### Post date: [October 7, 2022, 11:07am UTC](https://forum.social.plus/t/error-setting-image-url/543/1 "2022-10-07T11:07:37Z")

</div>

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.

```auto
        AmityUIKitManager.setup(apiKey: "", region: .US)
        
        client = try! AmityClient(apiKey: "", region: .US)

```

```auto
        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
            }

```

---

<div class="post-metadata">

### Author: ![au\_thanakorn](https://avatars.discourse-cdn.com/v4/letter/a/7c8e57/32.png) [@au\_thanakorn](https://forum.social.plus/u/au_thanakorn)
#### Post date: [October 10, 2022, 10:24am UTC](https://forum.social.plus/t/error-setting-image-url/543/2 "2022-10-10T10:24:07Z")

</div>

you can change from This:

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

```

To This:

```auto
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.

😀
