Class Index | File Index

Classes


Class KiiUser

Represents a KiiUser object
Defined in: KiiSDK.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Method Summary
Method Attributes Method Name and Description
<static>  
KiiUser.authenticate(userIdentifier, password, callbacks)
Authenticates a user with the server.
<static>  
KiiUser.authenticateWithRecoveryCode(recoveryCode, callbacks, expiresAt)
Asynchronously authenticates a user with the server using specified recovery code.
<static>  
KiiUser.authenticateWithToken(accessToken, callbacks, expiresAt)
Asynchronously authenticates a user with the server using specified access token.
<static>  
KiiUser.authenticateWithTotp(totpCode, callbacks, expiresAt)
Asynchronously authenticates a user with the server using specified totp code.
 
bucketWithName(bucketName)
Creates a reference to a bucket for this user

The bucket will be created/accessed within this user's scope
 
changeEmail(newEmail, callbacks)
Change email of logged in user.
 
changePhone(newPhoneNumber, callbacks)
Change phone number of logged in user.
<static>  
KiiUser.completeResetPassword(userIdentifier, pinCode, newPassword, callbacks)
Reset password with the PIN code in receipt SMS After KiiUser.resetPasswordWithNotificationMethod is called with "SMS_PIN", SMS includes the PIN code will be sent to the user's phone.
 
delete(callbacks)
Delete the user from the server
 
Return true if the user is disabled, false when enabled and undefined when user is not refreshed.
 
Creates a reference to a encrypted bucket for this user

The bucket will be created/accessed within this user's scope
<static>  
KiiUser.findUserByEmail(email, callbacks)
Find registered KiiUser with the email.
<static>  
KiiUser.findUserByPhone(phone, callbacks)
Find registered KiiUser with the phone.
<static>  
KiiUser.findUserByUsername(username, callbacks)
Find registered KiiUser with the user name.
 
get(key)
Gets the value associated with the given key
 
Get the access token for the user - only available if the user is currently logged in
 
Return the access token and token expire time in a object.
 
Get the country code associated with this user
 
Get the server's creation date of this user
<static>  
KiiUser.getCurrentUser()
The currently authenticated user
 
Get the display name associated with this user
 
Get the email address associated with this user
 
Get the status of the user's email verification.
 
Get the ID of the current KiiUser instance.
 
Get the social accounts that is linked to this user.
 
Get the locale associated with this user
 
 
Get the email of this user that has not been verified.
 
Get the phone of this user that has not been verified.
 
Get the phone number associated with this user
 
Get the status of the user's phone number verification.
 
Get the username of the given user
 
 
Get whether or not the user is pseudo user.
 
listTopics(callbacks, paginationKey)
Gets a list of topics in this user scope
<static>  
KiiUser.loggedIn()
Checks to see if there is a user authenticated with the SDK
<static>  
KiiUser.logOut()
Logs the currently logged-in user out of the KiiSDK
 
memberOfGroups(callbacks)
Retrieve a list of groups which the user is a member of
 
Get a specifically formatted string referencing the user

The user must exist in the cloud (have a valid UUID).
 
ownerOfGroups(callbacks)
Retrieve the groups owned by this user.
 
Instantiate push installation for this user.
 
Instantiate push subscription for this user.
 
putIdentity(identityData, password, callbacks, userFields, removeFields)
Sets credentials data and custom fields to pseudo user.
 
refresh(callbacks)
Updates the local user's data with the user data on the server

The user must exist on the server.
 
register(callbacks)
Registers a user with the server

The user object must have an associated email/password combination.
<static>  
KiiUser.registerAsPseudoUser(callbacks, userFields)
Registers a user as pseudo user with the server
 
Resend the email verification code to the user

This method will re-send the email verification to the currently logged in user
 
Resend the SMS verification code to the user

This method will re-send the SMS verification to the currently logged in user
<static>  
KiiUser.resetPassword(userIdentifier, callbacks)
Reset a user's password on the server

Reset a user's password on the server.
<static>  
KiiUser.resetPasswordWithNotificationMethod(userIdentifier, notificationMethod, callbacks)
Reset the password of user
Reset the password of user specified by given identifier.
 
save(callbacks)
Saves the latest user values to the server

If the user does not yet exist, it will NOT be created.
 
set(key, value)
Sets a key/value pair to a KiiUser

If the key already exists, its value will be written over.
 
setCountry(value)
Set the country code associated with this user
 
Set the display name associated with this user.
 
setLocale(value)
Set the locale associated with this user The locale argument must be BCP 47 language tag.
 
topicWithName(topicName)
Instantiate topic belongs to this user.
 
update(identityData, callbacks, userFields, removeFields)
Update user attributes.
 
updatePassword(fromPassword, toPassword, callbacks)
Update a user's password on the server

Update a user's password with the server.
<static>  
KiiUser.userWithCredentials(emailAddress, phoneNumber, username, password)
Create a user object to prepare for registration with credentials pre-filled

Creates an pre-filled user object for registration.
<static>  
KiiUser.userWithEmailAddress(emailAddress, password)
Create a user object to prepare for registration with credentials pre-filled

Creates an pre-filled user object for registration.
<static>  
KiiUser.userWithEmailAddressAndPhoneNumber(emailAddress, phoneNumber, password)
Create a user object to prepare for registration with credentials pre-filled

Creates an pre-filled user object for registration.
<static>  
KiiUser.userWithEmailAddressAndUsername(emailAddress, username, password)
Create a user object to prepare for registration with credentials pre-filled

Creates an pre-filled user object for registration.
<static>  
KiiUser.userWithID(userID)
Instantiate KiiUser that refers to existing user which has specified ID.
<static>  
KiiUser.userWithPhoneNumber(phoneNumber, password)
Create a user object to prepare for registration with credentials pre-filled

Creates an pre-filled user object for registration.
<static>  
KiiUser.userWithPhoneNumberAndUsername(phoneNumber, username, password)
Create a user object to prepare for registration with credentials pre-filled

Creates an pre-filled user object for registration.
<static>  
KiiUser.userWithURI(uri)
Generate a new KiiUser based on a given URI
<static>  
KiiUser.userWithUsername(username, password)
Create a user object to prepare for registration with credentials pre-filled

Creates an pre-filled user object for manipulation.
 
verifyPhoneNumber(verificationCode, callbacks)
Verify the current user's phone number

This method is used to verify the phone number of user currently logged in.
Class Detail
KiiUser()
Method Detail
<static> {Promise} KiiUser.authenticate(userIdentifier, password, callbacks)
Authenticates a user with the server. If authentication successful, the user is cached inside SDK as current user,and accessible via KiiUser.getCurrentUser(). User token and token expiration is also cached and can be get by KiiUser#getAccessTokenObject(). Access token won't be expired unless you set it explicitly by Kii.setAccessTokenExpiration().
If password or userIdentifier is invalid, callbacks.failure or reject callback of promise will be called.
  // example to use callbacks directly
  KiiUser.authenticate("myusername", "mypassword", {
      success: function(theAuthenticatedUser) {
          // do something with the authenticated user
      },
  
      failure: function(theUser, anErrorString) {
          // do something with the error response
      }
  });
  
  // example to use Promise
  KiiUser.authenticate("myusername", "mypassword").then(
      function(theAuthenticatedUser) {
          // do something with the authenticated user
      },
      function(error) {
          // do something with the error response
      }
  );
Parameters:
{String} userIdentifier
The username, validated email address, or validated phone number of the user to authenticate
{String} password
The password of the user to authenticate
{Object} callbacks Optional
An object with callback methods defined
{Method} callbacks.success
The callback method to call on a successful authentication request
{Method} callbacks.failure
The callback method to call on a failed authentication request
Returns:
{Promise} return promise object.
  • fulfill callback function: function(theAuthenticatedUser). theAuthenticatedUser is KiiUser instance.
  • reject callback function: function(error). error is an Error instance.
    • error.target is a KiiUser instance.If given password or userIdentifier is invalid, it will be null.
    • error.message

<static> {Promise} KiiUser.authenticateWithRecoveryCode(recoveryCode, callbacks, expiresAt)
Asynchronously authenticates a user with the server using specified recovery code. This method is non-blocking.

  // example to use callbacks directly
  KiiUser.authenticateWithRecoveryCode(recoveryCode, {
      success: function(theAuthenticatedUser) {
          // do something with the authenticated user
      },
  
      failure: function(theUser, anErrorString) {
          // do something with the error response
      }
  }, expiresAt);
  
  // example to use Promise
  KiiUser.authenticateWithRecoveryCode(recoveryCode).then(
      function(theAuthenticatedUser) {
          // do something with the authenticated user
      },
      function(error) {
          // do something with the error response
      }
  );
Parameters:
{String} recoveryCode
A valid recovery code
{Object} callbacks Optional
An object with callback methods defined
{Method} callbacks.success
The callback method to call on a successful authentication request
{Method} callbacks.failure
The callback method to call on a failed authentication request
{Date} expiresAt
Access token expire time that has received by KiiUser#getAccessTokenObject(). This param is optional and can be omitted.
Returns:
{Promise} return promise object.
  • fulfill callback function: function(theAuthenticatedUser). theAuthenticatedUser is KiiUser instance.
  • reject callback function: function(error). error is an Error instance.
    • error.target is a KiiUser instance.
    • error.message

<static> {Promise} KiiUser.authenticateWithToken(accessToken, callbacks, expiresAt)
Asynchronously authenticates a user with the server using specified access token. This method is non-blocking.

Specified expiresAt won't be used by SDK. IF login successful, we set this property so that you can get it later along with token by KiiUser#getAccessTokenObject().
Also, if successful, the user is cached inside SDK as current user and accessible via KiiUser.getCurrentUser().
Note that, if not specified, token expiration time is not cached and set to value equivalant to 275760 years.
If the specified token is expired, authenticataiton will be failed. Authenticate the user again to renew the token.
If expiresAt is invalid, callbacks.failure or reject callback of promise will be called.
  // example to use callbacks directly
  // Assume you stored the object get from KiiUser#getAccessTokenObject()
  // and now accessing by 'tokenObject' var.
  var token = tokenObject["access_token"];
  var expiresAt = tokenObject["expires_at"];
  expireDate.setHours(expireDate.getHours() + 24);
  KiiUser.authenticateWithToken(token, {
      success: function(theAuthenticatedUser) {
          // do something with the authenticated user
      },
  
      failure: function(theUser, anErrorString) {
          // do something with the error response
      }
  }, expiresAt);
  
  // example to use Promise
  // Assume you stored the object get from KiiUser#getAccessTokenObject()
  // and now accessing by 'tokenObject' var.
  var token = tokenObject["access_token"];
  var expiresAt = tokenObject["expires_at"];
  expireDate.setHours(expireDate.getHours() + 24);
  KiiUser.authenticateWithToken(token, null, expiresAt).then(
      function(theAuthenticatedUser) {
          // do something with the authenticated user
      },
      function(error) {
          // do something with the error response
      }
  );
Parameters:
{String} accessToken
A valid access token associated with the desired user
{Object} callbacks Optional
An object with callback methods defined
{Method} callbacks.success
The callback method to call on a successful authentication request
{Method} callbacks.failure
The callback method to call on a failed authentication request
{Date} expiresAt
Access token expire time that has received by KiiUser#getAccessTokenObject(). This param is optional and can be omitted.
Returns:
{Promise} return promise object.
  • fulfill callback function: function(theAuthenticatedUser). theAuthenticatedUser is KiiUser instance.
  • reject callback function: function(error). error is an Error instance.
    • error.target is a KiiUser instance.If expiresAt is invalid, it will be null.
    • error.message

<static> {Promise} KiiUser.authenticateWithTotp(totpCode, callbacks, expiresAt)
Asynchronously authenticates a user with the server using specified totp code. This method is non-blocking.

  // example to use callbacks directly
  KiiUser.authenticateWithTotp(totpCode, {
      success: function(theAuthenticatedUser) {
          // do something with the authenticated user
      },
  
      failure: function(theUser, anErrorString) {
          // do something with the error response
      }
  }, expiresAt);
  
  // example to use Promise
  KiiUser.authenticateWithTotp(totpCode).then(
      function(theAuthenticatedUser) {
          // do something with the authenticated user
      },
      function(error) {
          // do something with the error response
      }
  );
Parameters:
{String} totpCode
A valid totp code
{Object} callbacks Optional
An object with callback methods defined
{Method} callbacks.success
The callback method to call on a successful authentication request
{Method} callbacks.failure
The callback method to call on a failed authentication request
{Date} expiresAt
Access token expire time that has received by KiiUser#getAccessTokenObject(). This param is optional and can be omitted.
Returns:
{Promise} return promise object.
  • fulfill callback function: function(theAuthenticatedUser). theAuthenticatedUser is KiiUser instance.
  • reject callback function: function(error). error is an Error instance.
    • error.target is a KiiUser instance.
    • error.message

{KiiBucket} bucketWithName(bucketName)
Creates a reference to a bucket for this user

The bucket will be created/accessed within this user's scope
  var user = . . .; // a KiiUser
  var bucket = user.bucketWithName("myBucket");
Parameters:
{String} bucketName
The name of the bucket the user should create/access
Returns:
{KiiBucket} A working KiiBucket object

{Promise} changeEmail(newEmail, callbacks)
Change email of logged in user. If the email address verification is required by your app configuration, User's email would not changed to new one until the new email verification has been done. In this case, new mail address can be obtained by KiiUser#getPendingEmailAddress(). This API does not refresh the KiiUser automatically. Please execute KiiUser#refresh() before checking the value of KiiUser#getEmailAddress() or KiiUser#getPendingEmailAddress()
  // example to use callbacks directly
  var user = Kii.currentUser();
  user.changeEmail('mynewemail@kii.com', {
      success: function(theUser) {
          // do something on success
      },
  
      failure: function(theUser, anErrorString) {
          // do something with the error response
      }
  });
  
  // example to use Promise
  var user = Kii.currentUser();
  user.changeEmail('mynewemail@kii.com').then(
      function(theUser) {
          // do something on success
      },
      function(error) {
          // do something with the error response
      }
  );
Parameters:
{String} newEmail
The new email address to change to
{Object} callbacks Optional
An object with callback methods defined
{Method} callbacks.success
The callback method to call on a successful resend request
{Method} callbacks.failure
The callback method to call on a failed resend request
Returns:
{Promise} return promise object.
  • fulfill callback function: function(theUser). theUser is KiiUser instance which this method was called on.
  • reject callback function: function(error). error is an Error instance.
    • error.target is the KiiUser instance which this method was called on.
    • error.message

{Promise} changePhone(newPhoneNumber, callbacks)
Change phone number of logged in user. If the phone number verification is required by your app configuration, User's phone number would not changed to new one until the new phone number verification has been done. In this case, new phone can be obtained by KiiUser#getPendingPhoneNumber(). This API does not refresh the KiiUser automatically. Please execute KiiUser#refresh() before checking the value of KiiUser#getPhoneNumber() or KiiUser#getPendingPhoneNumber().
  // example to use callbacks directly
  var user = Kii.currentUser();
  user.changePhone('+19415551234', {
      success: function(theUser) {
          // do something on success
      },
  
      failure: function(theUser, anErrorString) {
          // do something with the error response
      }
  });
  
  // example to use Promise
  var user = Kii.currentUser();
  user.changePhone('+19415551234').then(
      function(theUser) {
          // do something on success
      },
      function(error) {
          // do something with the error response
      }
  );
Parameters:
{String} newPhoneNumber
The new phone number to change to
{Object} callbacks Optional
An object with callback methods defined
{Method} callbacks.success
The callback method to call on a successful resend request
{Method} callbacks.failure
The callback method to call on a failed resend request
Returns:
{Promise} return promise object.
  • fulfill callback function: function(theUser). theUser is KiiUser instance which this method was called on.
  • reject callback function: function(error). error is an Error instance.
    • error.target is the KiiUser instance which this method was called on.
    • error.message

<static> {Promise} KiiUser.completeResetPassword(userIdentifier, pinCode, newPassword, callbacks)
Reset password with the PIN code in receipt SMS After KiiUser.resetPasswordWithNotificationMethod is called with "SMS_PIN", SMS includes the PIN code will be sent to the user's phone. User can request the new password for login with the PIN code. Need to call method for authentication after the new password is determined.
  // Example using callback
  KiiUser.completeResetPassword("john.doe@kii.com", "new-password", "223789",
  {
      success: function() {
          // Succeeded.
      },
      failure: function(error) {
          // Handle error here.
      }
  });
  
  // Example using Promise
  KiiUser.completeResetPassword(
      "john.doe@kii.com", "new-password", "223789").then(function() {
          // Succeeded.
      }).catch(function(error) {
          // Handle error here.
      });
Parameters:
{String} userIdentifier
should be valid email address, global phone number or user identifier obtained by #getID.
{String} pinCode
Received PIN code.
{String} newPassword Optional
New password for login. If the 'Password Reset Flow' in app's security setting is set to 'Generate password', it would be ignored and null can be passed. In this case, new password is generated on Kii Cloud and sent to user's phone. Otherwise valid password is required.
{Object} callbacks Optional
object includes callback functions.
Returns:
{Promise} return promise object.
  • fulfill callback function: function(). No parameter used.
  • reject callback function: function(error). error is an Error instance.
    • error.message

{Promise} delete(callbacks)
Delete the user from the server
  // example to use callbacks directly
  var user = Kii.getCurrentUser(); // a KiiUser
  user.delete({
      success: function(theDeletedUser) {
          // do something
      },
  
      failure: function(theUser, anErrorString) {
          // do something with the error response
      }
  });
  
  // example to use Promise
  var user = Kii.getCurrentUser(); // a KiiUser
  user.delete().then(
      function(theDeletedUser) {
          // do something
      },
      function(error) {
          // do something with the error response
      }
  );
Parameters:
{Object} callbacks Optional
An object with callback methods defined
{Method} callbacks.success
The callback method to call on a successful delete request
{Method} callbacks.failure
The callback method to call on a failed delete request
Returns:
{Promise} return promise object.
  • fulfill callback function: function(theDeletedUser). theDeletedUser is KiiUser instance.
  • reject callback function: function(error). error is an Error instance.
    • error.target is the KiiUser instance which this method was called on.
    • error.message

disabled()
Return true if the user is disabled, false when enabled and undefined when user is not refreshed. Call KiiUser#refresh() prior calling this method to get correct status.

{KiiEncryptedBucket} encryptedBucketWithName(bucketName)
Creates a reference to a encrypted bucket for this user

The bucket will be created/accessed within this user's scope
  var user = . . .; // a KiiUser
  var bucket = user.encryptedBucketWithName("myBucket");
Parameters:
{String} bucketName
The name of the bucket the user should create/access
Returns:
{KiiEncryptedBucket} A working KiiEncryptedBucket object

<static> {Promise} KiiUser.findUserByEmail(email, callbacks)
Find registered KiiUser with the email.
If there are no user registers with the specified email or if there are but not verified email yet, callbacks.failure or reject callback of promise will be called.


Note:
  // example to use callbacks directly
  KiiUser.findUserByEmail("user_to_find@example.com", {
      success: function(theMatchedUser) {
          // Do something with the found user
      },
      failure: function(anErrorString) {
          // Do something with the error response
      }
  });
  
  // example to use Promise
  KiiUser.findUserByEmail("user_to_find@example.com").then(
      function(theMatchedUser) {
          // Do something with the matched user
      },
      function(error) {
          // Do something with the error response
      }
  );
Parameters:
{String} email
The email to find KiiUser who owns it.
Don't add prefix of "EMAIL:" described in REST API documentation. SDK will take care of it.
{Object} callbacks Optional
An object with callback methods defined. This argument is mandatory and can't be ommited.
{Method} callbacks.success
The callback method to call on a successful finding request.
{Method} callbacks.failure
The callback method to call on a failed finding request.
Returns:
{Promise} return promise object.
  • fulfill callback function: function(theMatchedUser). theMatchedUser is KiiUser instance.
  • reject callback function: function(error). error is an Error instance.
    • error.message

<static> {Promise} KiiUser.findUserByPhone(phone, callbacks)
Find registered KiiUser with the phone.
If there are no user registers with the specified phone or if there are but not verified phone yet, callbacks.failure or reject callback of promise will be called.

Note:
  // example to use callbacks directly
  KiiUser.findUserByPhone("phone_number_to_find", {
      success: function(theMatchedUser) {
          // Do something with the found user
      },
      failure: function(anErrorString) {
          // Do something with the error response
      }
  });
  
  // example to use Promise
  KiiUser.findUserByPhone("phone_number_to_find").then(
      function(theMatchedUser) {
          // Do something with the matched user
      },
      function(error) {
          // Do something with the error response
      }
  );
Parameters:
{String} phone
The phone number to find KiiUser who owns it.
Don't add prefix of "PHONE:" described in REST API documentation. SDK will take care of it.
{Object} callbacks Optional
An object with callback methods defined. This argument is mandatory and can't be ommited.
{Method} callbacks.success
The callback method to call on a successful finding request.
{Method} callbacks.failure
The callback method to call on a failed finding request.
Returns:
{Promise} return promise object.
  • fulfill callback function: function(theMatchedUser). theMatchedUser is KiiUser instance.
  • reject callback function: function(error). error is an Error instance.
    • error.message

<static> {Promise} KiiUser.findUserByUsername(username, callbacks)
Find registered KiiUser with the user name.
If there are no user registers with the specified user name, callbacks.failure or reject callback of promise will be called.

Note:
  // example to use callbacks directly
  KiiUser.findUserByUsername("user_name_to_find", {
      success: function(theMatchedUser) {
          // Do something with the found user
      },
      failure: function(anErrorString) {
          // Do something with the error response
      }
  });
  
  // example to use Promise
  KiiUser.findUserByUsername("user_name_to_find").then(
      function(theMatchedUser) {
          // Do something with the matched user
      },
      function(error) {
          // Do something with the error response
      }
  );
Parameters:
{String} username
The user name to find KiiUser who owns it.
Don't add prefix of "LOGIN_NAME:" described in REST API documentation. SDK will take care of it.
{Object} callbacks Optional
An object with callback methods defined. This argument is mandatory and can't be ommited.
{Method} callbacks.success
The callback method to call on a successful finding request.
{Method} callbacks.failure
The callback method to call on a failed finding request.
Returns:
{Promise} return promise object.
  • fulfill callback function: function(theMatchedUser). theMatchedUser is KiiUser instance.
  • reject callback function: function(error). error is an Error instance.
    • error.message

{Object} get(key)
Gets the value associated with the given key
  var user = . . .; // a KiiUser
  var score = user.get("score");
Parameters:
{String} key
The key to retrieve
Returns:
{Object} The object associated with the key. null or undefined if none exists

{String} getAccessToken()
Get the access token for the user - only available if the user is currently logged in
Returns:
{String}

{Object} getAccessTokenObject()
Return the access token and token expire time in a object.
Key Type Value
"access_token" String required for accessing KiiCloud
"expires_at" Date Access token expiration time, null if the user is not login user.
Returns:
{Object} Access token and token expires in a object.

{String} getCountry()
Get the country code associated with this user
Returns:
{String}

{String} getCreated()
Get the server's creation date of this user
Returns:
{String}

<static> {KiiUser} KiiUser.getCurrentUser()
The currently authenticated user
      var user = KiiUser.getCurrentUser();
Returns:
{KiiUser}

{String} getDisplayName()
Get the display name associated with this user
Returns:
{String}

{String} getEmailAddress()
Get the email address associated with this user
Returns:
{String}

{Boolean} getEmailVerified()
Get the status of the user's email verification. This field is assigned by the server
Returns:
{Boolean} true if the user's email address has been verified by the user, false otherwise. Could be undefined if haven't obtained value from server or not allowed to see the value. Should be used by current login user to check the email verification status.

{String} getID()
Get the ID of the current KiiUser instance.
Returns:
{String} Id of the user or null if the user has not saved to cloud.

{Object} getLinkedSocialAccounts()
Get the social accounts that is linked to this user. Refresh the user by KiiUser#refresh() prior call the method. Otherwise, it returns empty object.
Returns:
{Object} Social network name as key and account info as value.

{String} getLocale()
Get the locale associated with this user
Returns:
{String}

{String} getModified()
Deprecated:
Get the modified date of the given user, assigned by the server
Returns:
{String}

{String} getPendingEmailAddress()
Get the email of this user that has not been verified. When the user's email has been changed and email verification is required in you app configuration, New email is stored as pending email. After the new email has been verified, the address can be obtained by KiiUser.getEmailAddress
Returns:
{String} User's new email address has not been verified. null if no pending email field is included in refresh response or undefined when no refresh operation has been done before.

{String} getPendingPhoneNumber()
Get the phone of this user that has not been verified. When the user's phone has been changed and phone verification is required in you app configuration, New phone is stored as pending phone. After the new phone has been verified, the address can be obtained by KiiUser.getPhoneNumber
Returns:
{String} User's new phone number has not been verified. null if no pending phone field is included in refresh response or undefined when no refresh operation has been done before.

{String} getPhoneNumber()
Get the phone number associated with this user
Returns:
{String}

{Boolean} getPhoneVerified()
Get the status of the user's phone number verification. This field is assigned by the server
Returns:
{Boolean} true if the user's email address has been verified by the user, false otherwise Could be undefined if haven't obtained value from server or not allowed to see the value. Should be used by current login user to check the phone verification status.

{String} getUsername()
Get the username of the given user
Returns:
{String}

{String} getUUID()
Deprecated:
Use KiiUser.getId instead. Get the UUID of the given user, assigned by the server
Returns:
{String}

{Boolean} isPseudoUser()
Get whether or not the user is pseudo user. If this method is not called for current login user, calling KiiUser#refresh() method is necessary to get a correct value.
Returns:
{Boolean} whether this user is pseudo user or not.

{Promise} listTopics(callbacks, paginationKey)
Gets a list of topics in this user scope
  // example to use callbacks directly
  var user = . . .; // a KiiUser
  user.listTopics({
      success: function(topicList, nextPaginationKey) {
          // do something with the result
          for(var i=0; i<topicList.length; i++){
              var topic = topicList[i];
          }
          if (nextPaginationKey != null) {
              user.listTopics({
                  success: function(topicList, nextPaginationKey) {...},
                  failure: function(anErrorString) {...}
              }, nextPaginationKey);
          }
      },
      failure: function(anErrorString) {
          // do something with the error response
      }
  });
  
  // example to use callbacks directly
  var user = . . .; // a KiiUser
  user.listTopics().then(
      function(params) {
          var topicList = params[0];
          var nextPaginationKey = params[1];
          // do something with the result
          for(var i=0; i<topicList.length; i++){
              var topic = topicList[i];
          }
          if (nextPaginationKey != null) {
              user.listTopics(null, nextPaginationKey).then(
                  function(params) {...},
                  function(error) {...}
              );
          }
      },
      function(error) {
          // do something with the error response
      }
  );
Parameters:
{Object} callbacks Optional
An object with callback methods defined
{Method} callbacks.success
The callback method to call on a successful list request
{Method} callbacks.failure
The callback method to call on a failed list request
{String} paginationKey Optional
You can specify the pagination key with the nextPaginationKey passed by callbacks.success. If empty string or no string object is provided, this API regards no paginationKey specified.
Returns:
{Promise} return promise object.
  • fulfill callback function: function(params). params is Array instance.
    • params[0] is array of KiiTopic instances.
    • params[1] is string of nextPaginationKey.
  • reject callback function: function(error). error is an Error instance.
    • error.target is the KiiUser instance which this method was called on.
    • error.message

<static> KiiUser.loggedIn()
Checks to see if there is a user authenticated with the SDK
      if(KiiUser.loggedIn()) {
          // do something
      }

<static> KiiUser.logOut()
Logs the currently logged-in user out of the KiiSDK
      KiiUser.logOut();

{Promise} memberOfGroups(callbacks)
Retrieve a list of groups which the user is a member of
  // example to use callbacks directly
  var user = Kii.currentUser();
  user.memberOfGroups({
      success: function(theUser, groupList) {
          // do something with the results
          for(var i=0; i<groupList.length; i++) {
              var g = groupList[i]; // a KiiGroup object
          }
      },
  
      failure: function(theUser, anErrorString) {
          // do something with the error response
      }
  });
  
  // example to use Promise
  var user = Kii.currentUser();
  user.memberOfGroups().then(
      function(params) {
          // do something with the results
          var theUser = params[0];
          var groupList = params[1];
          for(var i=0; i<groupList.length; i++) {
              var g = groupList[i]; // a KiiGroup object
          }
      },
      function(error) {
          // do something with the error response
      }
  );
Parameters:
{Object} callbacks Optional
An object with callback methods defined
{Method} callbacks.success
The callback method to call on a successful resend request
{Method} callbacks.failure
The callback method to call on a failed resend request
Returns:
{Promise} return promise object.
  • fulfill callback function: function(params). params is Array instance.
    • params[0] is the KiiUser instance which this method was called on.
    • params[1] is array of KiiGroup instances.
  • reject callback function: function(error). error is an Error instance.
    • error.target is the KiiUser instance which this method was called on.
    • error.message

{String} objectURI()
Get a specifically formatted string referencing the user

The user must exist in the cloud (have a valid UUID).
  var user = . . .; // a KiiUser
  var uri = user.objectURI();
Returns:
{String} A URI string based on the given user. null if a URI couldn't be generated.

{Promise} ownerOfGroups(callbacks)
Retrieve the groups owned by this user. Group in the groupList does not contain all the property of group. To get all the property from cloud, a KiiGroup#refresh(callback) is necessary.
  // example to use callbacks directly
  var user = Kii.currentUser();
  user.ownerOfGroups({
      success: function(theUser, groupList) {
          // do something with the results
          for(var i=0; i<groupList.length; i++) {
              var g = groupList[i]; // a KiiGroup object
          }
      },
  
      failure: function(theUser, anErrorString) {
          // do something with the error response
      }
  });
  
  // example to use Promise
  var user = Kii.currentUser();
  user.ownerOfGroups().then(
      function(params) {
          // do something with the results
          var theUser = params[0];
          var groupList = params[1];
          for(var i=0; i<groupList.length; i++) {
              var g = groupList[i]; // a KiiGroup object
          }
      },
      function(error) {
          // do something with the error response
      }
  );
Parameters:
{Object} callbacks Optional
An object with callback methods defined
{Method} callbacks.success
The callback method to call on a successful resend request
{Method} callbacks.failure
The callback method to call on a failed resend request
Returns:
{Promise} return promise object.
  • fulfill callback function: function(params). params is Array instance.
    • params[0] is the KiiUser instance which this method was called on.
    • params[1] is array of KiiGroup instances.
  • reject callback function: function(error). error is an Error instance.
    • error.target is the KiiUser instance which this method was called on.
    • error.message

{KiiPushInstallation} pushInstallation()
Instantiate push installation for this user.
Returns:
{KiiPushInstallation} push installation object.

{KiiPushSubscription} pushSubscription()
Instantiate push subscription for this user.
Returns:
{KiiPushSubscription} push subscription object.

{Promise} putIdentity(identityData, password, callbacks, userFields, removeFields)
Sets credentials data and custom fields to pseudo user.

This method is exclusive to pseudo user.
password is mandatory and needs to provide at least one of login name, email address or phone number.
  // example to use callbacks directly
  var identityData = { "username": "__USER_NAME_" };
  var userFields = { "displayName":"__DISPLAY_NAME","score":12344300 };
  var removeFields = ["age"];
  user.putIdentity(
      identityData,
      "__PASSWORD__",
      {
          success: function(user) {
            // do something with the updated user.
          },
          failure: function(user, errorString) {
            // check error response.
          }
      },
      userFields,
      removeFields
  );
  
  // example to use Promise
  var identityData = { "username": "__USER_NAME_" };
  var userFields = { "displayName":"__DISPLAY_NAME","score":12344300 };
  var removeFields = ["age"];
  user.putIdentity(
      identityData,
      "__PASSWORD__",
      null,
      userFields,
      removeFields
  ).then(
      function(user) {
          // do something with the updated user.
      },
      function(error) {
          // check error response.
      }
  );
Parameters:
{Object} identityData
identityData.emailAddress
The user's email address. Valid pattern is ^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,6}$
identityData.phoneNumber
The user's phone number. Global phone valid pattern is ^[\\+]{1}[0-9]{2}. Note that you must provide country code in userFields if you speficy local phone number.
identityData.username
The user's desired username. Valid pattern is ^[a-zA-Z0-9-_\\.]{3,64}$
password
The user's password. Valid pattern is ^[\x20-\x7E]{4,50}$.
{Object} callbacks Optional
An object with callback methods defined. This argument is mandatory and can't be ommited.
{Method} callbacks.success
The callback method to call on a successful authentication request
{Method} callbacks.failure
The callback method to call on a failed authentication request
{Object} userFields
Custom Fields to add to the user. This is optional and can be omitted.
{Array} removeFields
An array of field names to remove from the user custom fields. Default fields are not removed from server. This is optional and can be omitted.
Returns:
{Promise} return promise object.
  • fulfill callback function: function(user). user is KiiUser instance which this method was called on.
  • reject callback function: function(error). error is an Error instance.
    • error.target is the KiiUser instance which this method was called on.
    • error.message

{Promise} refresh(callbacks)
Updates the local user's data with the user data on the server

The user must exist on the server. Local data will be overwritten.
  // example to use callbacks directly
  var user = Kii.getCurrentUser(); // a KiiUser
  user.refresh({
      success: function(theRefreshedUser) {
          // do something with the refreshed user
      },
  
      failure: function(theUser, anErrorString) {
          // do something with the error response
      }
  });
  
  // example to use Promise
  var user = Kii.getCurrentUser(); // a KiiUser
  user.refresh().then(
      function(theRefreshedUser) {
          // do something with the refreshed user
      },
      function(error) {
          // do something with the error response
      }
  );
Parameters:
{Object} callbacks Optional
An object with callback methods defined
{Method} callbacks.success
The callback method to call on a successful refresh request
{Method} callbacks.failure
The callback method to call on a failed refresh request
Returns:
{Promise} return promise object.
  • fulfill callback function: function(theRefreshedUser). theRefreshedUser is KiiUser instance.
  • reject callback function: function(error). error is an Error instance.
    • error.target is the KiiUser instance which this method was called on.
    • error.message

{Promise} register(callbacks)
Registers a user with the server

The user object must have an associated email/password combination.
  // example to use callbacks directly
  var user = KiiUser.userWithUsername("myusername", "mypassword");
  user.register({
      success: function(theAuthenticatedUser) {
          // do something with the authenticated user
      },
  
      failure: function(theUser, anErrorString) {
          // do something with the error response
      }
  });
  
  // example to use Promise
  var user = KiiUser.userWithUsername("myusername", "mypassword");
  user.register().then(
      function(params) {
          // do something with the authenticated user
      },
      function(error) {
          // do something with the error response
      }
  );
Parameters:
{Object} callbacks Optional
An object with callback methods defined
{Method} callbacks.success
The callback method to call on a successful registration request
{Method} callbacks.failure
The callback method to call on a failed registration request
Returns:
{Promise} return promise object.
  • fulfill callback function: function(theAuthenticatedUser). theAuthenticatedUser is KiiUser instance.
  • reject callback function: function(error). error is an Error instance.
    • error.target is a KiiUser instance.
    • error.message

<static> {Promise} KiiUser.registerAsPseudoUser(callbacks, userFields)
Registers a user as pseudo user with the server
  // example to use callbacks directly
  var userFields = {"displayName":"yourName", "country":"JP", "age":30};
  KiiUser.registerAsPseudoUser({
      success: function(theAuthenticatedUser) {
          // do something with the authenticated user
      },
  
      failure: function(theUser, anErrorString) {
          // do something with the error response
      }
  }, userFields);
  
  // example to use Promise
  var userFields = {"displayName":"yourName", "country":"JP", "age":30};
  KiiUser.registerAsPseudoUser(null, userFields).then(
      function(theAuthenticatedUser) {
          // do something with the authenticated user
      },
      function(error) {
          // do something with the error response
      }
  );
Parameters:
{Object} callbacks Optional
An object with callback methods defined. This argument is mandatory and can't be ommited.
{Method} callbacks.success
The callback method to call on a successful registration request
{Method} callbacks.failure
The callback method to call on a failed registration request
{Object} userFields
Custom Fields to add to the user. This is optional and can be omitted.
Returns:
{Promise} return promise object.
  • fulfill callback function: function(theAuthenticatedUser). theAuthenticatedUser is KiiUser instance.
  • reject callback function: function(error). error is an Error instance.
    • error.message

{Promise} resendEmailVerification(callbacks)
Resend the email verification code to the user

This method will re-send the email verification to the currently logged in user
  // example to use callbacks directly
  var user = Kii.currentUser();
  user.resendEmailVerification({
      success: function(theUser) {
          // do something
      },
  
      failure: function(theUser, anErrorString) {
          // do something with the error response
      }
  });
  
  // example to use Promise
  var user = Kii.currentUser();
  user.resendEmailVerification().then(
      function(theUser) {
          // do something
      },
      function(error) {
          // do something with the error response
      }
  );
Parameters:
{Object} callbacks Optional
An object with callback methods defined
{Method} callbacks.success
The callback method to call on a successful resend request
{Method} callbacks.failure
The callback method to call on a failed resend request
Returns:
{Promise} return promise object.
  • fulfill callback function: function(theUser). theUser is KiiUser instance which this method was called on.
  • reject callback function: function(error). error is an Error instance.
    • error.target is the KiiUser instance which this method was called on.
    • error.message

{Promise} resendPhoneNumberVerification(callbacks)
Resend the SMS verification code to the user

This method will re-send the SMS verification to the currently logged in user
  // example to use callbacks directly
  var user = Kii.currentUser();
  user.resendPhoneNumberVerification({
      success: function(theUser) {
          // do something
      },
  
      failure: function(theUser, anErrorString) {
          // do something with the error response
      }
  });
  
  // example to use Promise
  var user = Kii.currentUser();
  user.resendPhoneNumberVerification().then(
      function(theUser) {
          // do something
      },
      function(error) {
          // do something with the error response
      }
  );
Parameters:
{Object} callbacks Optional
An object with callback methods defined
{Method} callbacks.success
The callback method to call on a successful resend request
{Method} callbacks.failure
The callback method to call on a failed resend request
Returns:
{Promise} return promise object.
  • fulfill callback function: function(theUser). theUser is KiiUser instance which this method was called on.
  • reject callback function: function(error). error is an Error instance.
    • error.target is the KiiUser instance which this method was called on.
    • error.message

<static> {Promise} KiiUser.resetPassword(userIdentifier, callbacks)
Reset a user's password on the server

Reset a user's password on the server. The user is determined by the specified userIdentifier - which is an email address that has already been associated with an account. Reset instructions will be sent to that identifier.

Please Note: This will reset the user's access token, so if they are currently logged in - their session will no longer be valid.
  // example to use callbacks directly
  KiiUser.resetPassword("johndoe@example.com", {
      success: function() {
          // do something
      },
  
      failure: function(anErrorString) {
          // do something with the error response
      }
  });
  
  // example to use Promise
  KiiUser.resetPassword("johndoe@example.com").then(
      function() {
          // do something
      },
      function(error) {
          // do something with the error response
      }
  );
Parameters:
{String} userIdentifier
The user's email address
{Object} callbacks Optional
An object with callback methods defined
{Method} callbacks.success
The callback method to call on a successful update password request
{Method} callbacks.failure
The callback method to call on a failed update password request
Returns:
{Promise} return promise object.
  • fulfill callback function: function(). No parameter used.
  • reject callback function: function(error). error is an Error instance.
    • error.message

<static> {Promise} KiiUser.resetPasswordWithNotificationMethod(userIdentifier, notificationMethod, callbacks)
Reset the password of user
Reset the password of user specified by given identifier.
This api does not execute login after reset password.
  // example to use callbacks directly
  KiiUser.resetPasswordWithNotificationMethod("+819001234567", "SMS", {
      success: function() {
          // Operation succeeded.
      },
      failure: function(errString) {
          // Handle error.
      }
  });
  
  // example to use Promise
  KiiUser.resetPasswordWithNotificationMethod("+819001234567", "SMS").then(
      function() {
          // Operation succeeded.
      },
      function(error) {
          // Handle error.
      }
  );
Parameters:
{String} userIdentifier
should be valid email address, global phone number or user identifier obtained by #getID.
{String} notificationMethod
specify the destination of message include link of resetting password. must one of "EMAIL", "SMS" or "SMS_PIN". - "EMAIL": Send email include link URL to reset password or password. (Contents are depends on 'Password Reset Flow' setting in app's Security settings.) - "SMS" : Send SMS include link URL to reset password. - "SMS_PIN" : Send SMS include PIN Code for reset password. different type of identifier and destination can be used as long as user have verified email, phone. (ex. User registers both email and phone. Identifier is email and notificationMethod is SMS.)
{Object} callbacks Optional
object includes callback functions.
{Method} callbacks.success
called when operation succeeded.
{Method} callbacks.failure
called when operation failed.
Returns:
{Promise} return promise object.
  • fulfill callback function: function(). No parameter used.
  • reject callback function: function(error). error is an Error instance.
    • error.message

{Promise} save(callbacks)
Saves the latest user values to the server

If the user does not yet exist, it will NOT be created. Otherwise, the fields that have changed will be updated accordingly.
  // example to use callbacks directly
  var user = Kii.getCurrentUser(); // a KiiUser
  user.save({
      success: function(theSavedUser) {
          // do something with the saved user
      },
  
      failure: function(theUser, anErrorString) {
          // do something with the error response
      }
  });
  
  // example to use Promise
  var user = Kii.getCurrentUser(); // a KiiUser
  user.save().then(
      function(theSavedUser) {
          // do something with the saved user
      },
      function(error) {
          // do something with the error response
      }
  );
Parameters:
{Object} callbacks Optional
An object with callback methods defined
{Method} callbacks.success
The callback method to call on a successful save request
{Method} callbacks.failure
The callback method to call on a failed save request
Returns:
{Promise} return promise object.
  • fulfill callback function: function(theSavedUser). theSavedUser is KiiUser instance.
  • reject callback function: function(error). error is an Error instance.
    • error.target is the KiiUser instance which this method was called on.
    • error.message

set(key, value)
Sets a key/value pair to a KiiUser

If the key already exists, its value will be written over. If key is empty or starting with '_', it will do nothing. Accepted types are any JSON-encodable objects.
  var user = . . .; // a KiiUser
  user.set("score", 4298);
Parameters:
{String} key
The key to set. The key must not be a system key (created, metadata, modified, type, uuid) or begin with an underscore (_)
{Object} value
The value to be set. Object must be of a JSON-encodable type (Ex: dictionary, array, string, number, etc)

setCountry(value)
Set the country code associated with this user
Parameters:
{String} value
The country code to set. Must be 2 alphabetic characters. Ex: US, JP, CN
Throws:
{InvalidCountryException}
If the country code is not a valid format

setDisplayName(value)
Set the display name associated with this user. Cannot be used for logging a user in; is non-unique
Parameters:
{String} value
Must be between 1-50 alphanumeric characters.
Throws:
{InvalidDisplayNameException}
If the displayName is not a valid format

setLocale(value)
Set the locale associated with this user The locale argument must be BCP 47 language tag. Examples: "en": English "de-AT": German as used in Austria. "zh-Hans-CN": Chinese written in simplified characters as used in China.
Parameters:
{String} value
The locale to set.

{KiiTopic} topicWithName(topicName)
Instantiate topic belongs to this user.
Parameters:
{String} topicName
name of the topic. Must be a not empty string.
Returns:
{KiiTopic} topic instance.

{Promise} update(identityData, callbacks, userFields, removeFields)
Update user attributes.

If you want to update identity data of pseudo user, you must use KiiUser.putIdentity instead.
  // example to use callbacks directly
  var identityData = { "username": "__USER_NAME_" };
  var userFields = { "displayName":"__DISPLAY_NAME","score":12344300 };
  var removeFields = ["age"];
  user.update(
      identityData,
      {
          success: function(user) {
            // do something with the updated user.
          },
          failure: function(user, errorString) {
            // check error response.
          }
      },
      userFields,
      removeFields
  );
  
  // example to use Promise
  var identityData = { "username": "__USER_NAME_" };
  var userFields = { "displayName":"__DISPLAY_NAME","score":12344300 };
  var removeFields = ["age"];
  user.update(
      identityData,
      null,
      userFields,
      removeFields
  ).then(
      function(user) {
          // do something with the updated user.
      },
      function(error) {
          // check error response.
      }
  );
Parameters:
{Object} identityData
identityData.emailAddress
The user's email address. Valid pattern is ^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,6}$
identityData.phoneNumber
The user's phone number. Global phone valid pattern is ^[\\+]{1}[0-9]{2}. Note that you must provide country code in userFields if you specify local phone number.
identityData.username
The user's desired username. Valid pattern is ^[a-zA-Z0-9-_\\.]{3,64}$
{Object} callbacks Optional
An object with callback methods defined. This argument is mandatory and can't be ommited.
{Method} callbacks.success
The callback method to call on a successful authentication request
{Method} callbacks.failure
The callback method to call on a failed authentication request
{Object} userFields
Custom Fields to add to the user.
{Array} removeFields
An array of field names to remove from the user custom fields. Default fields are not removed from server.
Returns:
{Promise} return promise object.
  • fulfill callback function: function(user). user is KiiUser instance which this method was called on.
  • reject callback function: function(error). error is an Error instance.
    • error.target is a KiiUser instance.
    • error.message

{Promise} updatePassword(fromPassword, toPassword, callbacks)
Update a user's password on the server

Update a user's password with the server. The fromPassword must be equal to the current password associated with the account in order to succeed.
  // example to use callbacks directly
  var user = Kii.currentUser();
  user.updatePassword("oldpassword", "newpassword", {
      success: function(theUser) {
          // do something
      },
  
      failure: function(theUser, anErrorString) {
          // do something with the error response
      }
  });
  
  // example to use Promise
  var user = Kii.currentUser();
  user.updatePassword("oldpassword", "newpassword").then(
      function(theUser) {
          // do something
      },
      function(error) {
          // do something with the error response
      }
  );
Parameters:
{String} fromPassword
The user's current password
{String} toPassword
The user's desired password. Must be at least 4 characters, made up of alphanumeric and/or: @,#,$,%,^,&
{Object} callbacks Optional
An object with callback methods defined
{Method} callbacks.success
The callback method to call on a successful update password request
{Method} callbacks.failure
The callback method to call on a failed update password request
Returns:
{Promise} return promise object.
  • fulfill callback function: function(theUser). theUser is KiiUser instance which this method was called on.
  • reject callback function: function(error). error is an Error instance.
    • error.target is the KiiUser instance which this method was called on.
    • error.message

<static> KiiUser.userWithCredentials(emailAddress, phoneNumber, username, password)
Create a user object to prepare for registration with credentials pre-filled

Creates an pre-filled user object for registration. This user will not be authenticated until the registration method is called on it. It can be treated as any other KiiUser before it is registered.
  var user = KiiUser.userWithCredentials("johndoe@example.com", "+874012345678", "johndoe", "mypassword");
Parameters:
emailAddress
The user's email address
phoneNumber
The user's phone number
username
The user's desired username. Must be between 3 and 64 characters, which can include alphanumeric characters as well as underscores '_', dashes '-' and periods '.'
password
The user's password. Must be at least 4 characters, made up of alphanumeric and/or: @,#,$,%,^,&
Throws:
{InvalidPhoneNumberException}
If the phone number is not in the proper format
{InvalidEmailException}
If the phone number is not in the proper format
{InvalidUsernameException}
If the username is not in the proper format
{InvalidPasswordException}
If the password is not in the proper format
Returns:
a working KiiUser object

<static> KiiUser.userWithEmailAddress(emailAddress, password)
Create a user object to prepare for registration with credentials pre-filled

Creates an pre-filled user object for registration. This user will not be authenticated until the registration method is called on it. It can be treated as any other KiiUser before it is registered.
  var user = KiiUser.userWithEmailAddress("johndoe@example.com", "mypassword");
Parameters:
emailAddress
The user's email address
password
The user's password. Must be at least 4 characters, made up of alphanumeric and/or: @,#,$,%,^,&
Throws:
{InvalidPasswordException}
If the password is not in the proper format
{InvalidEmailException}
If the email address is not in the proper format
Returns:
a working KiiUser object

<static> KiiUser.userWithEmailAddressAndPhoneNumber(emailAddress, phoneNumber, password)
Create a user object to prepare for registration with credentials pre-filled

Creates an pre-filled user object for registration. This user will not be authenticated until the registration method is called on it. It can be treated as any other KiiUser before it is registered.
  var user = KiiUser.userWithEmailAddressAndPhoneNumber("johndoe@example.com", "+874012345678", "mypassword");
Parameters:
emailAddress
The user's email address
phoneNumber
The user's phone number
password
The user's password. Must be at least 4 characters, made up of alphanumeric and/or: @,#,$,%,^,&
Throws:
{InvalidPhoneNumberException}
If the phone number is not in the proper format
{InvalidPasswordException}
If the password is not in the proper format
{InvalidEmailException}
If the phone number is not in the proper format
Returns:
a working KiiUser object

<static> KiiUser.userWithEmailAddressAndUsername(emailAddress, username, password)
Create a user object to prepare for registration with credentials pre-filled

Creates an pre-filled user object for registration. This user will not be authenticated until the registration method is called on it. It can be treated as any other KiiUser before it is registered.
  var user = KiiUser.userWithEmailAddressAndUsername("johndoe@example.com", "johndoe", "mypassword");
Parameters:
emailAddress
The user's email address
username
The user's desired username. Must be between 3 and 64 characters, which can include alphanumeric characters as well as underscores '_', dashes '-' and periods '.'
password
The user's password. Must be at least 4 characters, made up of alphanumeric and/or: @,#,$,%,^,&
Throws:
{InvalidUsernameException}
If the username is not in the proper format
{InvalidPasswordException}
If the password is not in the proper format
{InvalidEmailException}
If the phone number is not in the proper format
Returns:
a working KiiUser object

<static> KiiUser.userWithID(userID)
Instantiate KiiUser that refers to existing user which has specified ID. You have to specify the ID of existing KiiUser. Unlike KiiObject, you can not assign ID in the client side.
NOTE: This API does not access to the server. After instantiation, call KiiUser#refresh to fetch the properties.
  var user = new KiiUser.userWithID("__USER_ID__");
Parameters:
userID
ID of the KiiUser to instantiate.
Throws:
{InvalidArgumentException}
when passed userID is empty or null.
Returns:
instance of KiiUser.

<static> KiiUser.userWithPhoneNumber(phoneNumber, password)
Create a user object to prepare for registration with credentials pre-filled

Creates an pre-filled user object for registration. This user will not be authenticated until the registration method is called on it. It can be treated as any other KiiUser before it is registered.
  var user = KiiUser.userWithPhoneNumber("+874012345678", "mypassword");
Parameters:
phoneNumber
The user's phone number
password
The user's password. Must be at least 4 characters, made up of alphanumeric and/or: @,#,$,%,^,&
Throws:
{InvalidPasswordException}
If the password is not in the proper format
{InvalidPhoneNumberException}
If the phone number is not in the proper format
Returns:
a working KiiUser object

<static> KiiUser.userWithPhoneNumberAndUsername(phoneNumber, username, password)
Create a user object to prepare for registration with credentials pre-filled

Creates an pre-filled user object for registration. This user will not be authenticated until the registration method is called on it. It can be treated as any other KiiUser before it is registered.
  var user = KiiUser.userWithPhoneNumberAndUsername("+874012345678", "johndoe", "mypassword");
Parameters:
phoneNumber
The user's phone number
username
The user's desired username. Must be between 3 and 64 characters, which can include alphanumeric characters as well as underscores '_', dashes '-' and periods '.'
password
The user's password. Must be at least 4 characters, made up of alphanumeric and/or: @,#,$,%,^,&
Throws:
{InvalidUsernameException}
If the username is not in the proper format
{InvalidPasswordException}
If the password is not in the proper format
{InvalidPhoneNumberException}
If the phone number is not in the proper format
Returns:
a working KiiUser object

<static> {KiiUser} KiiUser.userWithURI(uri)
Generate a new KiiUser based on a given URI
  var user = new KiiUser.userWithURI("kiicloud://myuri");
Parameters:
{String} uri
The URI of the object to be represented
Throws:
{InvalidURIException}
If the URI is not in the proper format
Returns:
{KiiUser} A new KiiUser with its parameters filled in from the URI

<static> KiiUser.userWithUsername(username, password)
Create a user object to prepare for registration with credentials pre-filled

Creates an pre-filled user object for manipulation. This user will not be authenticated until one of the authentication methods are called on it. It can be treated as any other KiiObject before it is authenticated.
  var user = KiiUser.userWithUsername("myusername", "mypassword");
Parameters:
username
The user's desired username. Must be between 3 and 64 characters, which can include alphanumeric characters as well as underscores '_', dashes '-' and periods '.'
password
The user's password. Must be between 4-50 characters, made up of ascii characters excludes control characters.
Throws:
{InvalidUsernameException}
If the username is not in the proper format
{InvalidPasswordException}
If the password is not in the proper format
Returns:
a working KiiUser object

{Promise} verifyPhoneNumber(verificationCode, callbacks)
Verify the current user's phone number

This method is used to verify the phone number of user currently logged in.
Verification code is sent from Kii Cloud when new user is registered with phone number or user requested to change their phone number in the application which requires phone verification.
(You can enable/disable phone verification through the console in developer.kii.com)
After the verification succeeded, new phone number becomes users phone number and user is able to login with the phone number.
To get the new phone number, please call #refresh() and call #getPhoneNumber()
Before completion of #refresh(), #getPhoneNumber() returns cached phone number. It could be old phone number or undefined.
  // example to use callbacks directly
  var user = Kii.currentUser();
  user.verifyPhoneNumber("012345", {
      success: function(theUser) {
          // do something
      },
  
      failure: function(theUser, anErrorString) {
          // do something with the error response
      }
  });
  
  // example to use Promise
  var user = Kii.currentUser();
  user.verifyPhoneNumber("012345").then(
      function(theUser) {
          // do something
      },
      function(error) {
          // do something with the error response
      }
  );
Parameters:
{String} verificationCode
The code which verifies the currently logged in user
{Object} callbacks Optional
An object with callback methods defined
{Method} callbacks.success
The callback method to call on a successful verification request
{Method} callbacks.failure
The callback method to call on a failed verification request
Returns:
{Promise} return promise object.
  • fulfill callback function: function(theUser). theUser is KiiUser instance which this method was called on.
  • reject callback function: function(error). error is an Error instance.
    • error.target is the KiiUser instance which this method was called on.
    • error.message

Documentation generated by JsDoc Toolkit 2.4.0 on Wed Sep 15 2021 05:31:34 GMT-0000 (UTC)