Skip to content
This repository has been archived by the owner on Nov 4, 2020. It is now read-only.

Latest commit

 

History

History
54 lines (37 loc) · 1.44 KB

updateemail.md

File metadata and controls

54 lines (37 loc) · 1.44 KB
description
initiates the update email flow that allows a user to change to a new email

updateEmail

Public Methods

Methods
updateEmail(configuration: UpdateEmailConfiguration) -> CompletableFuture<UpdateEmailResponse>

Returns

UpdateEmailResponse: Response<Boolean>()

The Completable resolves with a true boolean value if update email is successful and rejects with a specific error code if the request fails.

Example

class MagicActivity: AppCompatActivity() {

    lateinit var magic: Magic
    
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        
        magic = Magic(this, "YOUR_PUBLISHABLE_KEY")
    }
    
    // ⭐️Assuming user is logged in 
    fun updateEmail(v: View) {

        val configuration = UpdateEmailConfiguration("[email protected]")
        val completable = magic.user.updateEmail(configuration)
        completable.whenComplete { response: UpdateEmailResponse?, error: Throwable? ->
            if (response != null) {
                Log.d("Magic", response.result.toString()) // "True"
            } else {
                // handle error
            }
        }
    }
}

Associated Class

UpdateEmailConfiguration(showUI: Boolean? = true, email: String)

  • email The user email to update with.
  • showUI If true, show an out-of-the-box pending UI while the request is in flight.