Access user_metadata from profile on iOS?

On iOS, while using Lock, we’re adding a custom textfield to let user type in their first name.
I see this is then stored in user_metadata.

It seems like I can’t get this firstName from the profile though:

        .withStyle {
            $0.hideTitle = true
    .withOptions {
        $0.oidcConformant = true
        $0.scope = "openid profile email"
        $0.audience = "xxxxxxxxxxx"
        $0.initialScreen = .signup
        $0.allow = [.Signup]
        $0.customSignupFields = [
            CustomTextField(name: "firstName", placeholder: "Your first name", icon: LazyImage(name: "ic_person", bundle: Lock.bundle))
        $0.termsOfService = ""
        $0.privacyPolicy = ""
    .onAuth { credentials in
        if credentials) {
            guard let accessToken = credentials.accessToken else { return }
            self.testApiCallWithToken(token: accessToken, completionHandler: { (response) in
                // do smth
                .userInfo(withAccessToken: accessToken)
                .start { result in
                    switch result {
                    case .success(let profile):
                        // How do I get user firstName now? profile.user_metadata isnt accessible
                    case .failure(let error):
    .present(from: self)

Am I missing something?

Thank you in advance!

Found an answer to my question:

CustomTextField(name: "given_name", placeholder: "Your first name", storage: .rootAttribute, icon: LazyImage(name: "ic_person", bundle: Lock.bundle), contentType: .givenName)

I had to use parameters storage: rootAttribute and contentType: .givenName
For the custom textfield value to be added to the profile.

1 Like

Voila! Thanks for sharing that solution with the rest of community developers!

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.