description |
---|
initiates the update email flow that allows a user to change to a new email |
Methods |
---|
updateEmail( _ configuration: UpdateEmailConfiguration, response: (_ resp: Response<Bool>) |
updateEmail(_ configuration: UpdateEmailConfiguration) -> Promise <Bool> |
Promise<Bool>
: The promise resolves with a true boolean value if update email is successful and rejects with a specific error code if the request fails.
import MagicSDK
class MagicViewController: UIViewController {
let magic = Magic.shared
// Initiates the flow to update a user's current email to a new one.
func updateEmail() {
guard let magic = magic else { return }
// Assuming user is logged in
let configuration = UpdateEmailConfiguration(email: "[email protected]")
magic.user.updateEmail(configuration, response: { response in
guard let result = response.result
else { return print("Error:", response.error.debugDescription) }
print("Result", result)
})
}
}
UpdateEmailConfiguration(showUI: Bool = true, email: String)
email
The user email to update with.showUI
Iftrue
, show an out-of-the-box pending UI while the request is in flight.