This method allows you to add new users to your project through SDK. To create a new user account, simply provide the user email, password, display name and phone number as an argument to this function. Unlike dashboard, where you can create a user account without validation by just filling user details in a form, registering a new user account with SDK is little bit different. Because instead of directly registering the new user, we first verify that either the user is genuine to protect you from bogus users. So when you execute this function, we automatically send a verification code to the phone number provided in the argument and returns you a promise.

With this promise, you can access the confirmation method. So you can get the verification code from user through an input tag in html and validate the user by providing it to the confirmation method. On successful validation, we return you a success message and register the user automatically.

Register function accepts the following arguments


emailstringa valid email address
passwordstringshould be minimum six character long
displayNamestringcannot include digits or special characters
phonestringshould start with country code and cannot include spaces e.g. +923336335233

Register method returns the following code in form of promise


verification code sent to phone number and you use the confirmation method returned in the response of promise to verify the user.


provided phone number format is invalid


data format is invalid


email is associated to another account


failed to send the verification code


Once you submit the register request, we validate the data and send a code to the provided phone number. We do this to validate the user as a built in security mechanism. This is where we also return you a callback so that you could send us a confirmation request after promoting user about the code.

This function receives a single argument as illustrated below


codestringsix digit long numeric code

Upon execution, this method returns the following code in form of promise


user account has been created successfully


verification code is invalid


failed to verify the verification code


failed to register the account

Account registration has been illustrated in the example below

// Variable to hold the confirmRegistration
// method so that it could be used afterwards
var confirm = null;
// Get user data from the inputs and
// Submit request to the server
auth.register(email, password, displayName, phone).then((res) => {
  // Got the response
  // So checkout the response code
  switch(res.code) {
    case "PHONE-CODE-SENT": 
      // Verification code has been sent
      confirm = res.confirm;
// After getting response from registration request
// Prompt the user about the verification code
// and submit it to server with the confirm method
confirm(code).then((res) => {
  // Got the response
  // Checkout the response code
  switch(res.code) {
        // Account has been created successfully