Sign Up

Getting users registered with your application is the first step for user management.

Kii Cloud allows users to register with a username/password combination. Optionally, a registration can be performed with phone numbers and/or email addresses. When assigning an email address or phone number to a user, you can let Kii Cloud take the steps necessary to verify the credentials (either through a verification email or an SMS).

For more details on the user sign up, please read User Sign up and Sign in. You can also learn more on the email and phone verification by reading Email Address and Phone Number Verification.

User Sign-Up

The following snippet shows how to sign up a user with the username user_123456, the e-mail address user_123456@example.com, a phone number +819012345678 and a password 123ABC.

KiiUser.Builder builder;
builder = KiiUser.BuilderWithName("user_123456");
builder.WithEmail("user_123456@example.com");
builder.WithPhone("+819012345678");
KiiUser user = builder.Build();

user.Register("123ABC", (KiiUser registeredUser, Exception e) => {
  if (e != null)
  {
    // handle error
    return;
  }
});

The basic steps are as follows:

  1. Create a KiiUser instance by calling the BuilderWithName method with a username, optionally setting an email address and phone number with the WithEmail and WithPhone methods. Then call the Build method.
  2. Register this KiiUser instance with the Register method passing the password as parameter. At this point, a new account will be created and the user will be signed-in.

Sign Up without a Username

You can also create a new account without a username. To create an account with an e-mail address or a phone number, use the BuilderWithEmail and BuilderWithPhone methods respectively. Note that in this case, the email and phone number (SMS) verification must be disabled (please check the next section for more details on the verification mechanism).

Sign up with a Local Phone Number

When you want to specify a local phone number, please also set a valid 2-letter country code using the Country property like in the following example:

string phoneNumber = "09051903944";
string country = "JP";
string password = "123456";
KiiUser user = KiiUser.BuilderWithPhone(phoneNumber).Build();
user.Country = country; // 2-letter country code
user.Register(password, (KiiUser registeredUser, Exception e) => {
  if (e != null)
  {
    // handle error
    return;
  }
});

Enabling E-mail and/or Phone Verification

You can configure your application to verify the user's e-mail address and/or phone number. You can toggle the verification on/off on the developer portal as follows:

  1. Click the "Edit" button in your application console at the developer portal.

  2. Click "USER MANAGEMENT".

  3. Toggle SMS/Phone verification.

When enabled, the email address and/or phone number will be verified as follows:

E-mail Verification:

When the e-mail verification is enabled and an account is registered with an email address, Kii Cloud will send an e-mail to the user with a verification link. Signing in with the specified e-mail address will only be allowed if the user previously clicked on the verification link.

You can configure the "From" address of the notificaiton emails with the following UI.

Setting your Custom Email Templates

You can customize the content of the notification emails on the developer portal.

  1. Click the "EDIT" button of the target template to customize.

This will bring up an UI for defining the template for email subject and body.

You can use the following placeholders for defining the verification email template.

Placeholders To be replaced with
${url} A verification link (only in "Body").
${app.appID} The AppID of the application.
${user.displayName} The display name of the user.
${user.userID} The UserID of the user.
${user.unverifiedEmailAddress} The unverified email address of the user.
${user.loginName} The login name of the user.

You can use the following placeholders for defining the completion email template.

Placeholder To be replaced with
${app.appID} The AppID of the application.
${user.displayName} The display name of the user.
${user.userID} The UserID of the user.
${user.emailAddress} The verified email address of the user.
${user.loginName} The login name of the user.

Please put a space before and after a placeholder, especially when you are using ${url} (otherwise the link in the email body may not work properly).

Phone Verification:

When the phone verification is enabled and an account is registered with a phone number, Kii Cloud will send an SMS message with a verification code. Your application should then ask the user to type in the verification code to complete the registration. Signing-in with the specified phone number will only be allowed if the user previously submitted the correct verification code.

Please Note: You must specify a valid mobile phone number in an international phone number format (starting with + and your country code) in order to properly begin the SMS verification process.

After receiving the SMS verification code from the user, your application should call the VerifyPhone method to complete the verification process.

string code = "XYZXYZXYZ"; // Verification code
user.VerifyPhone(code, (KiiUser verifiedUser, Exception e) => {
  if (e != null)
  {
    // handle error
    return;
  }
});

Setting your Custom SMS Template

You can customize the content of the SMS message on the developer portal.

  1. On the "USER MANAGEMENT" configuration screen, toggle "Phone Number" verification ON.

This will bring up an UI for setting the SMS template.

You can use the following placeholders for defining the SMS template.

Placeholder To be replaced with
${code} The verification code.
${valid} The period of validity of the verification code (in hour).