selfRegisterUser

abstract fun selfRegisterUser(body: SelfRegisterBody, listener: RainbowListener<IRainbowContact, Unit>? = null)

Finalizes a user's registration within the Rainbow environment. This method serves as the concluding step following the user registration initiation via selfRegisterByEmail.

Upon obtaining the 6-digit code via email, use this method to complete the registration process.

You must provide one of the following properties to proceed:

Parameters

body

SelfRegisterBody the user information required for registration, including login email and password. Use the [SelfRegisterBody.Builder] to construct this parameter.

listener

RainbowListener<IRainbowContact, Unit> (optional) callback invoked upon completion of the operation. Set to null if not required.

Samples

import com.ale.infra.contact.IRainbowContact
import com.ale.infra.rest.listeners.RainbowError
import com.ale.infra.rest.listeners.RainbowListener
import com.ale.infra.rest.user.SelfRegisterBody
import com.ale.rainbowsdk.RainbowSdk
fun main() { 
   //sampleStart 
   val email = "your_email@domain.com"
val password = "Password"
val code = "123456"

RainbowSdk().user().selfRegisterByEmail(email, listener = object : RainbowListener<Unit, Unit> {
    override fun onSuccess(data: Unit) {
        val body = SelfRegisterBody.Builder()
            .loginEmail(email)
            .password(password)
            .temporaryToken(code)
            .firstName("FirstName")
            .lastName("LastName")
            .build()

        RainbowSdk().user().selfRegisterUser(body, listener = object : RainbowListener<IRainbowContact, Unit> {
            override fun onSuccess(data: IRainbowContact) {
                // The user is registered and can now connect to the Rainbow environment.
            }

            override fun onError(error: RainbowError<Unit>) {
                // Error handling
            }
        })
    }

    override fun onError(error: RainbowError<Unit>) {
        // Error handling
    }
}) 
   //sampleEnd
}