User Management

Register


let user = User(userId: valueMap[.email]!,
                    firstName: valueMap[.first_name]!,
                    lastName: valueMap[.last_name]!,
                    email: valueMap[.email]!,
                    mobileNumber: nil,
                    photo: nil,
                    address: nil)

AccountManager.register(user: user, password: password) { [weak self] errors in

                if errors.count > 0 {

                    self?.displayError(errors.first!.localizedDescription)

                } else {

                    self?.displaySuccess("You've registered successfully!")
                    self?.signIn(user: resultValidateUserInfo.user!, password: resultValidatePassword.password!)
                }
            }

Fetch User Info

AccountManager.fetchUser { (user, error) in
            if error != nil {
                NotificationUI.showMessage(type: .error, title: "Error", message: error!.localizedDescription)
            }

            if let updateUser = user {
                self.updateUI(user: updateUser)
            }
        }

If AccountManager.isBiometricsSignInEnabled is set to true, the biometric authentication process is automatically triggered when the fetchUser method is called. After the user provides valid biometric information, the session is restored.

Update User Info

AccountManager.updateUser(user: updatedUser) { (newUser, error) in
                if error != nil {
                    NotificationUI.showMessage(type: .error,
                                               title: "Update User Info",
                                               message: error!.localizedDescription)
                } else {
                    NotificationUI.showMessage(type: .success,
                                               title: "Update User Info",
                                               message: "User info has been updated")
                }
            }