Class KiiUser
- java.lang.Object
-
- com.kii.cloud.storage.KiiBaseObject
-
- com.kii.cloud.storage.KiiUser
-
- All Implemented Interfaces:
android.os.Parcelable
,KiiPushMessageSender
,KiiSubject
,KiiThingOwner
public final class KiiUser extends KiiBaseObject implements KiiSubject, KiiThingOwner, KiiPushMessageSender, android.os.Parcelable
Represent User on KiiCloud. There are two types of property of KiiUser, reserve and arbitrary.
Reserve fields
Reserve keys can not be used as the key of setter methods of KiiUser.
To set/get the value of these reserve fields, you use the setter/getter methods of these field.
- loginName
- emailAddress
- phoneNumber
- displayName
- country
- userID
- internalUserID
- phoneNumberVerified
- emailAddressVerified.
- _kiireserved_uri
Note that, internalUserID is for internal use only, there is no setter/getter methods of these.
Arbitrary fields
Arbitrary field includes any field choose by you, other than reserve field.
Arbitrary field can have String, integer, long, double, JSONArray, byte[], Uri type values.
setter/getter method of these type can be use to set/get the arbitrary field.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
KiiUser.Builder
KiiUser builder class.static class
KiiUser.NotificationMethod
-
Field Summary
Fields Modifier and Type Field Description static android.os.Parcelable.Creator<KiiUser>
CREATOR
Generates instances of Parcelable class from a Parcel.-
Fields inherited from class com.kii.cloud.storage.KiiBaseObject
mJSON, mJSONPatch
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description KiiBucket
bucket(java.lang.String bucketName)
Returns bucket belongs to this user.static KiiUser.Builder
builderWithEmail(java.lang.String email)
Create Builder with the email address.static KiiUser.Builder
builderWithIdentifier(java.lang.String identifier)
Create builder with identifier.static KiiUser.Builder
builderWithLocalPhone(java.lang.String phone, java.lang.String country)
Create Builder with local phone number.static KiiUser.Builder
builderWithName(java.lang.String userName)
Create Builder with the user name.static KiiUser.Builder
builderWithPhone(java.lang.String phone)
Create Builder with the phone number.static int
changeEmail(KiiUserCallBack callback, java.lang.String email)
static void
changeEmail(java.lang.String email)
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 bygetPendingEmail()
.
This API does not refresh the KiiUser automatically.
Please executerefresh()
before checking the value ofgetEmail()
orgetPendingEmail()
NOTE: This api access to server.int
changePassword(KiiUserCallBack callBack, java.lang.String newPassword, java.lang.String oldPassword)
Asynchronous call forchangePassword(String, String)
.
Background task will be initiated to execute the task.void
changePassword(java.lang.String newPassword, java.lang.String oldPassword)
Change the password of user.static int
changePhone(KiiUserCallBack callback, java.lang.String phoneNumber)
static void
changePhone(java.lang.String phoneNumber)
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 bygetPendingPhone()
.
This API does not refresh the KiiUser automatically.
Please executerefresh()
before checking the value ofgetPhone()
orgetPendingPhone()
NOTE: This api access to server.static void
completeResetPassword(java.lang.String identifier, java.lang.String pinCode, java.lang.String newPassword)
Reset password with the PIN code in receipt SMS.static void
completeResetPassword(java.lang.String identifier, java.lang.String pinCode, java.lang.String newPassword, KiiCallback<java.lang.Void> callback)
Reset password with the PIN code in receipt SMS.static KiiUser
createByUri(android.net.Uri uri)
Instantiate KiiUser from the Uri.
After instantiate, call {linkrefresh()
} to fetch properties.static KiiUser
createWithEmail(java.lang.String username, java.lang.String email)
Instantiate KiiUser with username and Email.static KiiUser
createWithPhone(java.lang.String username, java.lang.String phone)
Instantiate KiiUser with username and Phone.static KiiUser
createWithUsername(java.lang.String username)
Instantiate KiiUser with username.void
delete()
Delete this user from KiiCloud.int
delete(KiiUserCallBack callBack)
Asynchronous call fordelete()
.
Background task will be initiated to execute the task.int
describeContents()
boolean
disabled()
Return true if the user is disabled, false otherwise.KiiEncryptedBucket
encryptedBucket(java.lang.String bucketName)
Returns the KiiEncryptedBucket instance belongs to this userboolean
equals(java.lang.Object user)
Return true when the specified KiiUser is in following conditions.static KiiUser
findUserByEmail(java.lang.String email)
Find registered KiiUser with the email.static int
findUserByEmail(java.lang.String email, KiiUserCallBack callback)
Asynchronous version offindUserByEmail(String)
.static KiiUser
findUserByPhone(java.lang.String phone)
Find registered KiiUser with the phone.static int
findUserByPhone(java.lang.String phone, KiiUserCallBack callback)
Asynchronous version offindUserByPhone(String)
Background task will be initiated to execute the task.static KiiUser
findUserByUserName(java.lang.String username)
Find registered KiiUser with the user name.static int
findUserByUserName(java.lang.String username, KiiUserCallBack callback)
Asynchronous version offindUserByUserName(String)
Background task will be initiated to execute the task.java.lang.String
getAccessToken()
Get the access token.When successfully login by user credentials,
SDK cached the user token, which is returned by this API.android.os.Bundle
getAccessTokenBundle()
Return the access tokens in a bundle.java.lang.String
getCountry()
Get the country of this userstatic KiiUser
getCurrentUser()
Get current login user.java.lang.String
getDisplayname()
Get the displayName of this userjava.lang.String
getEmail()
Get the email of this userjava.lang.String
getID()
Returns the userID.java.util.Map<KiiSocialNetworkConnector.Provider,SocialAccountInfo>
getLinkedSocialAccounts()
Returns the social account info linked by this user.LocaleContainer
getLocale()
Get the locale(BCP47) of this userjava.lang.String
getPendingEmail()
Get the email of this user that has not been verified.java.lang.String
getPendingPhone()
Get the phone of this user that has not been verified.java.lang.String
getPhone()
Get the phone number of this userjava.lang.String
getThingOwnerID()
Get the ID of this owner with prefix.java.lang.String
getUsername()
Get the username of this userint
hashCode()
boolean
isEmailVerified()
Return true if Email address is verified.
Note: Email verification is done from the verification email sent to the registered email.
Before call this method, callingrefresh()
is necessary to get the verification status.boolean
isLinkedWithSocialProvider(KiiSocialNetworkConnector.Provider provider)
Return true if this instance is linked by specified social provider.static boolean
isLoggedIn()
Checks whether there is a user authenticated with the SDK.boolean
isPhoneVerified()
Return true if Phone number is verified.boolean
isPseudoUser()
Return true if this instance is pseudo user.static boolean
isValidCountry(java.lang.String country)
Checks whether the country is valid or not.
Valid country definition is: Not null or empty Matches ^[A-Z]{2}$static boolean
isValidDisplayName(java.lang.String displayname)
Checks whether the display name is valid or not.
Valid display name definition is: Not null or empty Between 1 to 50 characters.static boolean
isValidEmail(java.lang.String email)
Checks whether the email address is valid or not.
Valid email definition is: Not null or empty MatchesPatterns.EMAIL_ADDRESS
static boolean
isValidGlobalPhone(java.lang.String phone)
Checks whether specified number is a valid international phone number.
Acceptable pattern is: Matches ^[\\+][0-9.-]+static boolean
isValidLocalPhone(java.lang.String phone)
Checks whether the phone number is valid or not.
Valid Phone number definition is: Not null or empty Matches ^[0-9]static boolean
isValidPassword(java.lang.String password)
Checks whether the password is valid or not.
Password should be organized with ascii character exclude control characters.static boolean
isValidPhone(java.lang.String phone)
Checks whether the phone number is valid or not.
This matches both international and local phone number.
Acceptable pattern is: Matches [\\+]?[0-9.-]+static boolean
isValidUserName(java.lang.String username)
Checks whether the username is valid or not.
Valid username definition is:
Not null.
matches [a-zA-Z0-9-_\\.]{3,64}$KiiListResult<KiiTopic>
listTopics()
Returns the list of topics in this user scope.void
listTopics(KiiCallback<KiiListResult<KiiTopic>> callback)
Asynchronous call forlistTopics()
.KiiListResult<KiiTopic>
listTopics(java.lang.String paginationKey)
Returns the next page of list of topics in this user scope.void
listTopics(java.lang.String paginationKey, KiiCallback<KiiListResult<KiiTopic>> callback)
Asynchronous call forlistTopics(String)
.static int
logIn(KiiUserCallBack callBack, java.lang.String userIdentifier, java.lang.String password)
Asynchronous call forlogIn(String, String)
.
Background task will be initiated to execute the task.static KiiUser
logIn(java.lang.String userIdentifier, java.lang.String password)
LogIn with username/email and password.
If successful, the user is cached inside SDK as current user,
and accessible viagetCurrentUser()
.
This user token is also cached and used by the SDK when the access token is required.
Access token won't be expired unless you set it explicitly byKii.setAccessTokenExpiration(long)
.static int
logInWithLocalPhone(KiiUserCallBack callBack, java.lang.String localPhoneNumber, java.lang.String password, java.lang.String country)
Asynchronous call forlogInWithLocalPhone(String, String, String)
.
Background task will be initiated to execute the task.static KiiUser
logInWithLocalPhone(java.lang.String localPhoneNumber, java.lang.String password, java.lang.String country)
LogIn with local phone number, country and password.
Register with phone number is supported by two ways, one is with international phone number such as +818034068125 and another is with local phone number such as 08034068125 and two digit country code.static KiiUser
loginWithStoredCredentials()
Try to login using stored user credentials.
The user credentials is stored in the SharedPreferences automatically, If you initialized SDK with android.content.Context.static void
loginWithStoredCredentials(KiiCallback<KiiUser> callback)
Asynchronous call forloginWithStoredCredentials()
.
Background task will be initiated to execute the task.static int
loginWithToken(KiiUserCallBack callBack, java.lang.String token)
Asynchronous call forloginWithToken(String)
.
Background task will be initiated to execute the task.static void
loginWithToken(LoginCallBack callback, java.lang.String token, long expiresAt)
Asynchronous call forloginWithToken(String, long)
.
Background task will be initiated to execute the task.static KiiUser
loginWithToken(java.lang.String token)
LogIn with access token.
If successful, the user is cached inside SDK as current user,
and accessible viagetCurrentUser()
.
This user token is also cached and used by the SDK when the access token is required.
Note that, token expiration time is not cached and Maximum value(Integer.MAX_VALUE + System.currentTimeMillis()) is applied.static KiiUser
loginWithToken(java.lang.String token, long expiresAt)
LogIn with access token.
Specified expiresAt won't be used by SDK.static KiiUser
loginWithToken(java.lang.String token, long expiresAt, java.lang.String refreshToken)
LogIn with access token.
If successful, the user is cached inside SDK as current user and accessible viagetCurrentUser()
.
If the specified token is expired, login will be failed, uselogIn(String, String)
orlogInWithLocalPhone(String, String, String)
to renew the token in that case.static void
loginWithToken(java.lang.String token, long expiresAt, java.lang.String refreshToken, KiiCallback<KiiUser> callback)
Asynchronous call forloginWithToken(String, long, String)
.
Background task will be initiated to execute the task.static void
logOut()
Logout current user.
Cached user information and token cleared.java.util.List<KiiGroup>
memberOfGroups()
Returns the list of groups which the user is a member of.int
memberOfGroups(KiiUserCallBack callBack)
Asynchronous call formemberOfGroups()
.
Background task will be initiated to execute the task.java.util.List<KiiGroup>
ownerOfGroups()
Returns the groups owned by this user.int
ownerOfGroups(KiiUserCallBack callBack)
Asynchronous version ofownerOfGroups()
.
Background task will be initiated to execute the task.static KiiPushInstallation
pushInstallation()
Get KiiPushInstallation instance of current logged in user.static KiiPushInstallation
pushInstallation(boolean development)
Get KiiPushInstallation instance of current logged in user.static KiiPushInstallation
pushInstallation(KiiPushInstallation.PushBackend backend)
Get KiiPushInstallation instance of current logged in user with specified push backend.static KiiPushInstallation
pushInstallation(KiiPushInstallation.PushBackend backend, boolean development)
Get KiiPushInstallation instance of current logged in user with specified push backend.KiiPushSubscription
pushSubscription()
Get KiiPushSubscription instance of the user.void
putIdentity(IdentityData identityData, UserFields userFields, java.lang.String password)
Puts identity data to pseudo user.void
putIdentity(IdentityData identityData, UserFields userFields, java.lang.String password, KiiUserPutIdentityCallback callBack)
Asynchronous call forputIdentity(IdentityData, UserFields, String)
.void
refresh()
Getting user profile from KiiCloud and refresh related properties.
Updates locally done will be overwritten.
NOTE: This api access to server.int
refresh(KiiUserCallBack callBack)
Asynchronous call forrefresh()
.
Background task will be initiated to execute the task.int
register(KiiUserCallBack callBack, java.lang.String password)
Asynchronous call forregister(String)
.void
register(java.lang.String password)
Register this user on KiiCloud.
NOTE: This api access to server.static KiiUser
registerAsPseudoUser(UserFields userFields)
Register this user as pseudo user on KiiCloud.static void
registerAsPseudoUser(UserFields userFields, KiiUserRegisterCallback callBack)
Asynchronous call forregisterAsPseudoUser(UserFields)
.static void
requestResendEmailVerification()
Request for re-send email verification code to server.static int
requestResendEmailVerification(KiiUserCallBack callback)
Asynchronous call forrequestResendEmailVerification()
.
Background task will be initiated to execute the task.static void
requestResendPhoneVerificationCode()
Request for re-send phone verification code to server.static int
requestResendPhoneVerificationCode(KiiUserCallBack callback)
Asynchronous call forrequestResendPhoneVerificationCode()
.
Background task will be initiated to execute the task.static int
resetPassword(KiiUserCallBack callBack, java.lang.String identifier)
Asynchronous call forresetPassword(String)
.
Background task will be initiated to execute the task.static void
resetPassword(java.lang.String identifier)
Reset the password of current login user.
Url for password reset will be sent to the specified identifier.static void
resetPassword(java.lang.String identifier, KiiUser.NotificationMethod notificationMethod)
Reset password of user specified by given identifier.static void
resetPassword(java.lang.String identifier, KiiUser.NotificationMethod notificationMethod, KiiCallback<java.lang.Void> callback)
Asynchronous call forresetPassword(String, com.kii.cloud.storage.KiiUser.NotificationMethod)
.
Background task will be initiated to execute the task.void
setCountry(java.lang.String country)
Set 2-letters country code of this user.void
setDisplayname(java.lang.String displayname)
Set the displayName of this user.void
setLocale(LocaleContainer locale)
Set the locale(BCP47) of this userorg.json.JSONObject
toJSON()
Returns JSON representation of this KiiUser.static KiiTopic
topic(java.lang.String name)
Get instance of user scope topic.KiiTopic
topicOfThisUser(java.lang.String name)
Get instance of user scope topic.java.lang.String
toString()
Returns String representation of JSONObject get fromtoJSON()
android.net.Uri
toUri()
Returns URI of this KiiUser.void
update(IdentityData identityData, UserFields userFields)
Update user attributes.void
update(IdentityData identityData, UserFields userFields, KiiUserUpdateCallback callBack)
Asynchronous version ofupdate(IdentityData, UserFields)
.void
update(UserFields userFields)
Update user attributes.void
update(UserFields userFields, KiiUserUpdateCallback callBack)
Asynchronous version ofupdate(UserFields)
.static KiiUser
userWithID(java.lang.String userID)
Instantiate KiiUser that refers to existing user which has specified ID.int
verifyPhone(KiiUserCallBack callBack, java.lang.String code)
Asynchronous call forverifyPhone(String)
.
Background task will be initiated to execute the task.void
verifyPhone(java.lang.String code)
Verify this user's phone number with verification code in SMS sent by KiiCloud.void
writeToParcel(android.os.Parcel dest, int flags)
-
Methods inherited from class com.kii.cloud.storage.KiiBaseObject
getBoolean, getBoolean, getByteArray, getDouble, getDouble, getInt, getInt, getJsonArray, getJSONArray, getJSONObject, getJSONOfArbitraryFields, getLong, getLong, getObject, getObject, getString, getString, getUri, has, keySet, remove, removeReserveProperty, set, set, set, set, set, set, set, set, set
-
-
-
-
Field Detail
-
CREATOR
public static final android.os.Parcelable.Creator<KiiUser> CREATOR
Generates instances of Parcelable class from a Parcel.
-
-
Method Detail
-
getUsername
@Nullable public java.lang.String getUsername()
Get the username of this user- Returns:
- username.
-
disabled
public boolean disabled()
Return true if the user is disabled, false otherwise. Callrefresh()
orrefresh(KiiUserCallBack)
prior calling this method to get correct status.
-
getEmail
@Nullable public java.lang.String getEmail()
Get the email of this user- Returns:
- email. null if user does not register email.
-
getPendingEmail
@Nullable public java.lang.String getPendingEmail()
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 bygetEmail()
- Returns:
- User's new email address requires verification.
- See Also:
getEmail()
,changeEmail(String)
-
getPhone
@Nullable public java.lang.String getPhone()
Get the phone number of this user- Returns:
- phone number. null if user does not register phone number.
-
getPendingPhone
@Nullable public java.lang.String getPendingPhone()
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 number can be obtained bygetPhone()
.- Returns:
- User's new phone number requires verification.
- See Also:
getPhone()
,changePhone(String)
-
getDisplayname
@Nullable public java.lang.String getDisplayname()
Get the displayName of this user- Returns:
- displayName. null if user does not register displayName.
-
getCountry
@Nullable public java.lang.String getCountry()
Get the country of this user- Returns:
- country. null if user does not register country.
-
getLocale
@Nullable public LocaleContainer getLocale()
Get the locale(BCP47) of this user- Returns:
-
setLocale
public void setLocale(@NonNull LocaleContainer locale)
Set the locale(BCP47) of this user- Parameters:
locale
-
-
setDisplayname
public void setDisplayname(@NonNull java.lang.String displayname)
Set the displayName of this user. displayName length is 1-50 chars (not byte), and allow Multi-Byte input.- Parameters:
displayname
-- Throws:
java.lang.IllegalArgumentException
- when displayname is not acceptable. For details please refer toisValidDisplayName(String)
-
setCountry
public void setCountry(@NonNull java.lang.String country)
Set 2-letters country code of this user. This property available string is A-Z. (like "US", "JP", "CN" and so on.)
NOTE: This property is used for phone number validation by SMS.
If phone number input string is NOT international telephone number format, add country code by server-side using this property. Use this code for internationalize the number to send verification SMS from KiiCloud.- Parameters:
country
- Must be 2-letters with UpperCase (A-Z).- Throws:
java.lang.IllegalArgumentException
- when country is not acceptable format. For details please refer toisValidCountry(String)
-
logIn
@WorkerThread @NonNull public static KiiUser logIn(@NonNull java.lang.String userIdentifier, @NonNull java.lang.String password) throws java.io.IOException, BadRequestException, UnauthorizedException, ForbiddenException, ConflictException, NotFoundException, UndefinedException
LogIn with username/email and password.
If successful, the user is cached inside SDK as current user,
and accessible viagetCurrentUser()
.
This user token is also cached and used by the SDK when the access token is required.
Access token won't be expired unless you set it explicitly byKii.setAccessTokenExpiration(long)
. User token can be get bygetAccessToken()
.
From next time, it is possible to login by access tokenloginWithToken(String)
, until the token is expired.
NOTE: This api access to server. Should not be executed in UI/Main thread.- Parameters:
userIdentifier
- one of username, phone or email.
For phone or email, don't add prefix of "PHONE:" or "EMAIL:" described in REST api documentation. SDK will take care of those prefix. Phone number must be in international format(i.e +818034068125). Separators(i.e dot(.) or hyphen(-)), if present in phone number, will be removed prior to authenticate with KiiCloud. If you want to login with localphone, uselogInWithLocalPhone(String, String, String)
password
- refer toisValidPassword(String)
for available characters.- Returns:
- authenticated KiiUser
- Throws:
java.io.IOException
- When network related error has happened.UndefinedException
NotFoundException
ConflictException
ForbiddenException
UnauthorizedException
BadRequestException
java.lang.IllegalStateException
- When SDK is not initialized.java.lang.IllegalArgumentException
- When userIdentifier or password either or both not acceptable. For details please refer toisValidUserName(String)
,isValidGlobalPhone(String)
,isValidEmail(String)
,isValidPassword(String)
- See Also:
logOut()
,getCurrentUser()
,logIn(KiiUserCallBack, String, String)
,loginWithToken(String)
,getAccessToken()
-
logInWithLocalPhone
@WorkerThread @NonNull public static KiiUser logInWithLocalPhone(@NonNull java.lang.String localPhoneNumber, @NonNull java.lang.String password, @NonNull java.lang.String country) throws java.io.IOException, BadRequestException, UnauthorizedException, ForbiddenException, ConflictException, NotFoundException, UndefinedException
LogIn with local phone number, country and password.
Register with phone number is supported by two ways, one is with international phone number such as +818034068125 and another is with local phone number such as 08034068125 and two digit country code. This method is intended to login to KiiCloud when registration is performed by local phone number and country code. To login with international phone number refer tologIn(String, String)
orlogIn(KiiUserCallBack, String, String)
If successful, the user is cached inside SDK as current user,
and accessible viagetCurrentUser()
.
This user token is also cached and used by the SDK when the access token is required.
Access token won't be expired unless you set it explicitly byKii.setAccessTokenExpiration(long)
. User token can be get bygetAccessToken()
.
From next time, it is possible to login by access tokenloginWithToken(String)
, until the token is expired.
NOTE: This api access to server. Should not be executed in UI/Main thread.- Parameters:
localPhoneNumber
- Local phone number.password
- refer toisValidPassword(String)
for available characters.country
- 2-letters country code.- Returns:
- authenticated KiiUser
- Throws:
java.io.IOException
- When network related error has happened.UndefinedException
NotFoundException
ConflictException
ForbiddenException
UnauthorizedException
BadRequestException
java.lang.IllegalStateException
- When SDK is not initialized.java.lang.IllegalArgumentException
- When one of the localPhoneNumber,password,country or all not acceptable. For details please refer toisValidLocalPhone(String)
,isValidCountry(String)
,isValidPassword(String)
- See Also:
logOut()
,getCurrentUser()
,logIn(KiiUserCallBack, String, String)
,loginWithToken(String)
,getAccessToken()
-
loginWithToken
@WorkerThread @NonNull public static KiiUser loginWithToken(@NonNull java.lang.String token) throws java.io.IOException, BadRequestException, UnauthorizedException, ForbiddenException, ConflictException, NotFoundException, UndefinedException
LogIn with access token.
If successful, the user is cached inside SDK as current user,
and accessible viagetCurrentUser()
.
This user token is also cached and used by the SDK when the access token is required.
Note that, token expiration time is not cached and Maximum value(Integer.MAX_VALUE + System.currentTimeMillis()) is applied. If you want token expiration time also be cached, useloginWithToken(String, long)
instead.
If the specified token is expired, login will be failed, uselogIn(String, String)
orlogInWithLocalPhone(String, String, String)
to renew the token in this case.
NOTE: This api access to server. Should not be executed in UI/Main thread.- Parameters:
token
- Access token for the user.- Returns:
- authenticated KiiUser
- Throws:
java.io.IOException
- When network related error has happened.UndefinedException
NotFoundException
ConflictException
ForbiddenException
UnauthorizedException
BadRequestException
java.lang.IllegalStateException
- When SDK is not initialized.java.lang.IllegalArgumentException
- When the specified token is null or empty.- See Also:
logOut()
,getCurrentUser()
,logIn(String, String)
,getAccessToken()
-
loginWithToken
@NonNull public static KiiUser loginWithToken(@NonNull java.lang.String token, long expiresAt) throws java.io.IOException, BadRequestException, UnauthorizedException, ForbiddenException, ConflictException, NotFoundException, UndefinedException
LogIn with access token.
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 bygetAccessTokenBundle()
Also, if successful, the user is cached inside SDK as current user and accessible viagetCurrentUser()
.
If the specified token is expired, login will be failed, uselogIn(String, String)
orlogInWithLocalPhone(String, String, String)
to renew the token in that case.
NOTE: This API access to server. Should not be executed in UI/Main thread.- Parameters:
token
- Access token for the user.expiresAt
- Access token expire time that has received bygetAccessTokenBundle()
- Returns:
- Authenticated KiiUser
- Throws:
java.io.IOException
- When network related error has happened.UndefinedException
NotFoundException
ConflictException
ForbiddenException
UnauthorizedException
BadRequestException
java.lang.IllegalStateException
- When SDK is not initialized.java.lang.IllegalArgumentException
- When the specified token is null or empty.- See Also:
getCurrentUser()
,logIn(String, String)
,getAccessTokenBundle()
-
loginWithToken
@NonNull public static KiiUser loginWithToken(@NonNull java.lang.String token, long expiresAt, @NonNull java.lang.String refreshToken) throws java.io.IOException, BadRequestException, UnauthorizedException, ForbiddenException, ConflictException, NotFoundException, UndefinedException
LogIn with access token.
If successful, the user is cached inside SDK as current user and accessible viagetCurrentUser()
.
If the specified token is expired, login will be failed, uselogIn(String, String)
orlogInWithLocalPhone(String, String, String)
to renew the token in that case.
NOTE: This API access to server. Should not be executed in UI/Main thread.- Parameters:
token
- Access token for the user.expiresAt
- Access token expire time.refreshToken
- Refresh token for the user. bygetAccessTokenBundle()
- Returns:
- Authenticated KiiUser
- Throws:
java.io.IOException
- When network related error has happened.UndefinedException
NotFoundException
ConflictException
ForbiddenException
UnauthorizedException
BadRequestException
java.lang.IllegalStateException
- When SDK is not initialized.java.lang.IllegalArgumentException
- When the specified token is null or empty.- See Also:
getCurrentUser()
,logIn(String, String)
,getAccessTokenBundle()
-
loginWithToken
public static void loginWithToken(@NonNull LoginCallBack callback, @NonNull java.lang.String token, long expiresAt)
Asynchronous call forloginWithToken(String, long)
.
Background task will be initiated to execute the task. This api doesn't extend the time for actual accessToken expiration.- Parameters:
callback
- notifies event.token
- Access token of the user.expiresAt
- Access token expire time that has received bygetAccessTokenBundle()
- Throws:
java.lang.IllegalStateException
- When SDK has not initialized.java.lang.IllegalArgumentException
- When callback is null or specified token is null/empty.
-
loginWithToken
public static void loginWithToken(@NonNull java.lang.String token, long expiresAt, @NonNull java.lang.String refreshToken, @NonNull KiiCallback<KiiUser> callback)
Asynchronous call forloginWithToken(String, long, String)
.
Background task will be initiated to execute the task. This api doesn't extend the time for actual accessToken expiration.- Parameters:
token
- Access token of the user.expiresAt
- Access token expire time that has receivedrefreshToken
- Refresh token of the user.callback
- notifies event.- Throws:
java.lang.IllegalStateException
- When SDK has not initialized.java.lang.IllegalArgumentException
- When callback is null or specified token is null/empty.
-
getAccessToken
@Nullable public java.lang.String getAccessToken()
Get the access token.When successfully login by user credentials,
SDK cached the user token, which is returned by this API.- Returns:
- Access token of the user or null if user is not logged in.
-
loginWithStoredCredentials
@NonNull public static KiiUser loginWithStoredCredentials() throws UserCredentialsNotFoundException
Try to login using stored user credentials.
The user credentials is stored in the SharedPreferences automatically, If you initialized SDK with android.content.Context. Following properties are loaded from persistent storage.
In order to use this feature, you need to initialize the SDK usingKii.initialize(Context, String, String, Kii.Site)
- ID
- Username
- isEmailVerified
- PendingEmail
- Phone
- isPhoneVerified
- PendingPhone
- Country
- DisplayName
- AccessToken
- RefreshToken
- AccessTokenExpiresAt
refresh()
prior to call getters..- Returns:
- Authenticated KiiUser
- Throws:
UserCredentialsNotFoundException
- When valid user credentials has not stored.- See Also:
Kii.initialize(android.content.Context, String, String)
,Kii.initialize(android.content.Context, String, String, String)
,Kii.initialize(android.content.Context, String, String, com.kii.cloud.storage.Kii.Site)
-
loginWithStoredCredentials
public static void loginWithStoredCredentials(@NonNull KiiCallback<KiiUser> callback)
Asynchronous call forloginWithStoredCredentials()
.
Background task will be initiated to execute the task.- Parameters:
callback
- notifies event.
-
changePassword
@WorkerThread public void changePassword(@NonNull java.lang.String newPassword, @NonNull java.lang.String oldPassword) throws java.io.IOException, BadRequestException, UnauthorizedException, ForbiddenException, ConflictException, NotFoundException, UndefinedException
Change the password of user.
NOTE: This api access to server. Should not be executed in UI/Main thread.- Parameters:
oldPassword
- old password of this user.newPassword
- to be set. refer toisValidPassword(String)
for available characters.- Throws:
java.io.IOException
- When network related error has happened.UndefinedException
NotFoundException
ConflictException
ForbiddenException
BadRequestException
UnauthorizedException
- When user unauthorized error has happened.java.lang.IllegalArgumentException
- When wrong password has given. For details please refer toisValidPassword(String)
java.lang.IllegalStateException
- When SDK is not initialized OR the authenticated user is different from this user OR user has not sign up to the cloud.- See Also:
changePassword(KiiUserCallBack, String, String)
-
register
@WorkerThread public void register(@NonNull java.lang.String password) throws java.io.IOException, BadRequestException, UnauthorizedException, ForbiddenException, ConflictException, NotFoundException, UndefinedException
Register this user on KiiCloud.
NOTE: This api access to server. Should not be executed in UI/Main thread.- Parameters:
password
- refer toisValidPassword(String)
for available characters.- Throws:
java.io.IOException
- When network related error has happened.UndefinedException
NotFoundException
ConflictException
ForbiddenException
UnauthorizedException
BadRequestException
java.lang.IllegalStateException
- When KiiClient is not initialized.java.lang.IllegalArgumentException
- When wrong password has given. For details please refer toisValidPassword(String)
- See Also:
register(KiiUserCallBack, String)
-
registerAsPseudoUser
@WorkerThread @NonNull public static KiiUser registerAsPseudoUser(@Nullable UserFields userFields) throws BadRequestException, UnauthorizedException, ForbiddenException, ConflictException, NotFoundException, UndefinedException, java.io.IOException
Register this user as pseudo user on KiiCloud. After call this method, get access token bygetAccessToken()
and have to take care of keeping it.
NOTE: This API access to server. Should not be executed in UI/Main thread.- Parameters:
userFields
- Optional. If null is passed, display name, country and other custom fields won't be set. To set those fields, create UserFields instance and pass to this API. Fields set to the current KiiUser instance will be ignored.- Returns:
- Registered new KiiUser.
- Throws:
java.io.IOException
UndefinedException
NotFoundException
ConflictException
ForbiddenException
UnauthorizedException
BadRequestException
-
putIdentity
@WorkerThread public void putIdentity(@NonNull IdentityData identityData, @Nullable UserFields userFields, @NonNull java.lang.String password) throws AlreadyHasIdentityException, java.lang.IllegalArgumentException, java.lang.IllegalStateException, BadRequestException, UnauthorizedException, ForbiddenException, ConflictException, NotFoundException, UndefinedException, java.io.IOException
Puts identity data to pseudo user. This method is exclusive to pseudo user.Local modification done by
setCountry(String)
,setDisplayname(String)
, and other setter methods inKiiUser
will be ignored. Please make sure to set new values in UserFields.You can set both global and local phone number to
IdentityData.Builder.newWithPhone(String)
orIdentityData.Builder.withPhone(String)
. If you set local phone number, you must set country code byUserFields.putCountry(String)
.
NOTE: This API access to server. Should not be executed in UI/Main thread.- Parameters:
identityData
- Mandatory.userFields
- Optional. If null is passed, display name, country and other custom field won't be updated.password
- Mandatory. New password is required to put Identity.- Throws:
java.lang.IllegalStateException
- if this methods is called for user who has identity.java.lang.IllegalArgumentException
- one or more arguments are invalid.AlreadyHasIdentityException
- if a pseudo user already has identity. This exception may be thrown if previous putting identity is failed by network error.java.io.IOException
UndefinedException
NotFoundException
ConflictException
ForbiddenException
UnauthorizedException
BadRequestException
-
update
@WorkerThread public void update(@NonNull UserFields userFields) throws BadRequestException, UnauthorizedException, ForbiddenException, ConflictException, NotFoundException, UndefinedException, java.io.IOException
Update user attributes. This method can be used both pseudo user and non pseudo user.Local modification done by
setCountry(String)
,setDisplayname(String)
, and other setter methods inKiiUser
will be disappeared. Please make sure to set new values in UserFields.
NOTE: This API access to server. Should not be executed in UI/Main thread.- Parameters:
userFields
- User fields to be updated.- Throws:
java.lang.IllegalArgumentException
- When specified userFields is null or empty.java.lang.IllegalStateException
- Thrown if SDK has not initialized or user is not logged-in.java.io.IOException
UndefinedException
NotFoundException
ConflictException
ForbiddenException
UnauthorizedException
BadRequestException
-
update
public void update(@NonNull UserFields userFields, @NonNull KiiUserUpdateCallback callBack)
Asynchronous version ofupdate(UserFields)
. Update user attributes. This method can be used both pseudo user and non pseudo user.Note: Local modification done by
setCountry(String)
,setDisplayname(String)
, and other setter methods inKiiUser
will be disappeared. Please make sure to set new values in UserFields.Note: Exceptions occurred in this method are notified by
KiiUserUpdateCallback.onUpdateCompleted(KiiUser, Exception)
. However, only IllegalArgumentException is thrown from this method ifKiiUserUpdateCallback
is null.- Parameters:
userFields
- User fields to be updated.callBack
- notifies events. called on main thread. This is a mandatory parameter.- Throws:
java.lang.IllegalArgumentException
- if callBack is null.java.lang.IllegalStateException
- If SDK has not initialized or user is not logged-in.- See Also:
update(IdentityData, UserFields)
-
update
@WorkerThread public void update(@Nullable IdentityData identityData, @Nullable UserFields userFields) throws java.lang.IllegalArgumentException, BadRequestException, UnauthorizedException, ForbiddenException, ConflictException, NotFoundException, UndefinedException, java.io.IOException
Update user attributes.This method is exclusive to non pseudo user. If you want to update some fields of pseudo user, you must use
putIdentity(IdentityData, UserFields, String)
instead.Local modification done by
setCountry(String)
,setDisplayname(String)
, and other setter methods inKiiUser
will be disappeared. Please make sure to set new values in UserFields.
NOTE: This API access to server. Should not be executed in UI/Main thread.- Parameters:
identityData
- Optional. If null is passed, Identity data would not be updated and current value would be retained.userFields
- Optional. If null is passed, display name, country and other custom fields won't be updated.- Throws:
java.lang.IllegalArgumentException
- if bothIdentityData
andUserFields
are null or empty.IdentityData
is not null for pseudo user.java.lang.IllegalStateException
- Thrown if SDK has not initialized or user is not logged-in.java.io.IOException
UndefinedException
NotFoundException
ConflictException
ForbiddenException
UnauthorizedException
BadRequestException
-
update
public void update(@Nullable IdentityData identityData, @Nullable UserFields userFields, @NonNull KiiUserUpdateCallback callBack) throws java.lang.IllegalArgumentException
Asynchronous version ofupdate(IdentityData, UserFields)
. Update user attributes. This method is exclusive to non pseudo user. If you want to update some fields of pseudo user, you must useputIdentity(IdentityData, UserFields, String)
instead.Note: Local modification done by
setCountry(String)
,setDisplayname(String)
, and other setter methods inKiiUser
will be disappeared. Please make sure to set new values in UserFields.Note: Exceptions occurred in this method are notified by
KiiUserUpdateCallback.onUpdateCompleted(KiiUser, Exception)
. However, only IllegalArgumentException is thrown from this method ifKiiUserUpdateCallback
is null.- Parameters:
identityData
- Optional. If null is passed, Identity data would not be updated and current value would be retained.userFields
- Optional. If null is passed, display name, country and other custom fields won't be updated.callBack
- notifies events. called on main thread. This is a mandatory parameter.- Throws:
java.lang.IllegalArgumentException
- if callBack is null.java.lang.IllegalStateException
- If SDK has not initialized or user is not logged-in.- See Also:
update(IdentityData, UserFields)
-
delete
@WorkerThread public void delete() throws java.io.IOException, BadRequestException, UnauthorizedException, ForbiddenException, ConflictException, NotFoundException, UndefinedException
Delete this user from KiiCloud. If user currently logged in,
Logout will be done and cached user info and token in the SDK will be cleared.
NOTE: This api access to server. Should not be executed in UI/Main thread.- Throws:
java.io.IOException
- When network related error has happened.UndefinedException
NotFoundException
ConflictException
ForbiddenException
BadRequestException
UnauthorizedException
java.lang.IllegalStateException
- When SDK is not initialized OR user doesn't exist in cloud.- See Also:
delete(KiiUserCallBack)
-
refresh
@WorkerThread public void refresh() throws java.io.IOException, BadRequestException, UnauthorizedException, ForbiddenException, ConflictException, NotFoundException, UndefinedException
Getting user profile from KiiCloud and refresh related properties.
Updates locally done will be overwritten.
NOTE: This api access to server. Should not be executed in UI/Main thread.- Throws:
java.io.IOException
- When network related error has happened.UndefinedException
NotFoundException
ConflictException
ForbiddenException
BadRequestException
UnauthorizedException
java.lang.IllegalStateException
- When SDK is not initialized OR user does not exist in the cloud.- See Also:
refresh(KiiUserCallBack)
-
logIn
public static int logIn(@NonNull KiiUserCallBack callBack, @NonNull java.lang.String userIdentifier, @NonNull java.lang.String password)
Asynchronous call forlogIn(String, String)
.
Background task will be initiated to execute the task.- Parameters:
callBack
- notifies event.userIdentifier
- one of username, phone number or email.password
- refer toisValidPassword(String)
for available characters.- Returns:
- id of this task. Can be used to cancel this operation by
Kii.cancelTask(int)
-
logInWithLocalPhone
public static int logInWithLocalPhone(@NonNull KiiUserCallBack callBack, @NonNull java.lang.String localPhoneNumber, @NonNull java.lang.String password, @NonNull java.lang.String country)
Asynchronous call forlogInWithLocalPhone(String, String, String)
.
Background task will be initiated to execute the task.- Parameters:
callBack
- notifies event.localPhoneNumber
- Local phone number.password
- refer toisValidPassword(String)
for available characters.country
- 2-letters country code.- Returns:
- id of this task. Can be used to cancel this operation by
Kii.cancelTask(int)
-
loginWithToken
public static int loginWithToken(@NonNull KiiUserCallBack callBack, @NonNull java.lang.String token)
Asynchronous call forloginWithToken(String)
.
Background task will be initiated to execute the task.- Parameters:
callBack
- notifies event.token
- Access token of the user.- Returns:
- id of this task. Can be used to cancel this operation by
Kii.cancelTask(int)
-
createWithEmail
@NonNull public static KiiUser createWithEmail(@NonNull java.lang.String username, @NonNull java.lang.String email)
Instantiate KiiUser with username and Email.- Parameters:
email
- Email address.- Returns:
- Instance of KiiUser.
- Throws:
java.lang.IllegalArgumentException
- when username or email is not acceptable format. for details please refer toisValidUserName(String)
,isValidEmail(String)
-
createWithPhone
@NonNull public static KiiUser createWithPhone(@NonNull java.lang.String username, @NonNull java.lang.String phone)
Instantiate KiiUser with username and Phone.- Parameters:
phone
- Phone number. We'll remove the separators(i.e dot(.) or hyphen(-)), if these are present in the specified number.- Returns:
- Instance of KiiUser.
- Throws:
java.lang.IllegalArgumentException
- when username or phone is not acceptable format. For details please refer toisValidUserName(String)
,isValidPhone(String)
-
createWithUsername
@NonNull public static KiiUser createWithUsername(@NonNull java.lang.String username)
Instantiate KiiUser with username.- Parameters:
username
- Username- Returns:
- Instance of KiiUser.
- Throws:
java.lang.IllegalArgumentException
- when username is not acceptable format. For details refer toisValidUserName(String)
-
builderWithPhone
@NonNull public static KiiUser.Builder builderWithPhone(@NonNull java.lang.String phone)
Create Builder with the phone number.- Parameters:
phone
- of the user to be registered. We'll remove the separators(i.e dot(.) or hyphen(-)), if these are present in the specified number.- Returns:
- Builder instance.
- Throws:
java.lang.IllegalArgumentException
- when the phone number is invalid. For details refer toisValidPhone(String)
-
builderWithLocalPhone
@NonNull public static KiiUser.Builder builderWithLocalPhone(@NonNull java.lang.String phone, @NonNull java.lang.String country)
Create Builder with local phone number.- Parameters:
phone
- Local phone number of the user to be registered. We'll remove the separators(i.e dot(.) or hyphen(-)), if these are present in the specified number.country
- Country of the user.- Returns:
- Builder instance.
- Throws:
java.lang.IllegalArgumentException
- when the phone number is invalid. For details refer toisValidPhone(String)
java.lang.IllegalArgumentException
- when country is not acceptable format. For details refer toisValidCountry(String)
-
builderWithName
@NonNull public static KiiUser.Builder builderWithName(@NonNull java.lang.String userName)
Create Builder with the user name.- Parameters:
userName
- of the user to be registered.- Returns:
- Builder instance.
- Throws:
java.lang.IllegalArgumentException
- when the user name is invalid. For details refer toisValidUserName(String)
-
builderWithEmail
@NonNull public static KiiUser.Builder builderWithEmail(@NonNull java.lang.String email)
Create Builder with the email address.- Parameters:
email
- address of the user to be registered.- Returns:
- Builder instance.
- Throws:
java.lang.IllegalArgumentException
- when the email address is invalid. For details refer toisValidEmail(String)
-
builderWithIdentifier
@NonNull public static KiiUser.Builder builderWithIdentifier(@NonNull java.lang.String identifier)
Create builder with identifier. Identifier is one of phone number, email or user name. When called multiple times, it will update existing phone number, email address or user name. Some strings can be accepted as both user name and phone number. If such string is passed to this constructor as identifier, then phone number is prior to user name. String of email address is in different class against user name and phone number. So email address is always identified correctly. This method accepts local phone number as identifier but if You use local phone number as identifier, You need to set country code to KiiUser instance built byKiiUser.Builder.build()
.- Parameters:
identifier
- Phone number, email address or user name.- Returns:
- Builder instance.
- Throws:
java.lang.IllegalArgumentException
- when the identifier is not phone number, email address, user name. For details refer toisValidPhone(String)
,isValidEmail(String)
,isValidUserName(String)
-
register
public int register(@NonNull KiiUserCallBack callBack, @NonNull java.lang.String password)
Asynchronous call forregister(String)
.
Background task will be initiated to execute the task.- Parameters:
callBack
- notifies event.password
- refer toisValidPassword(String)
for available characters.- Returns:
- id of this task. Can be used to cancel this operation by
Kii.cancelTask(int)
-
registerAsPseudoUser
public static void registerAsPseudoUser(@Nullable UserFields userFields, @NonNull KiiUserRegisterCallback callBack)
Asynchronous call forregisterAsPseudoUser(UserFields)
.
Background task will be initiated to execute the task.- Parameters:
userFields
- Optional. If null is passed, display name, country and other custom fields won't be set. To set those fields, create UserFields instance and pass to this API. Fields set to the current KiiUser instance will be ignored.callBack
- notifies event.
-
changePassword
public int changePassword(@NonNull KiiUserCallBack callBack, @NonNull java.lang.String newPassword, @NonNull java.lang.String oldPassword)
Asynchronous call forchangePassword(String, String)
.
Background task will be initiated to execute the task.- Parameters:
callBack
- notifies event.newPassword
- to be changed.oldPassword
- of the user.- Returns:
- id of this task. Can be used to cancel this operation by
Kii.cancelTask(int)
-
putIdentity
public void putIdentity(@NonNull IdentityData identityData, @Nullable UserFields userFields, @NonNull java.lang.String password, @NonNull KiiUserPutIdentityCallback callBack) throws java.lang.IllegalArgumentException
Asynchronous call forputIdentity(IdentityData, UserFields, String)
. Puts identity data to pseudo user. This method is exclusive to pseudo user.Note: Local modification done by
setCountry(String)
,setDisplayname(String)
, and other setter methods inKiiUser
will be ignored. Please make sure to set new values in UserFields.Note: Exceptions occurred in this method are notified by
KiiUserPutIdentityCallback.onPutIdentityCompleted(KiiUser, Exception)
. However, only IllegalArgumentException is thrown from this method ifKiiUserPutIdentityCallback
is null.- Parameters:
identityData
- Mandatory.userFields
- Optional. If null is passed, display name, country and other custom field won't be updated.password
- Mandatory. New password is required to put Identity.callBack
- notifies events. called on main thread. This is a mandatory parameter.- Throws:
java.lang.IllegalArgumentException
- whenKiiUserPutIdentityCallback
is null.- See Also:
putIdentity(IdentityData, UserFields, String)
-
delete
public int delete(@NonNull KiiUserCallBack callBack)
Asynchronous call fordelete()
.
Background task will be initiated to execute the task.- Parameters:
callBack
- notifies event.- Returns:
- id of this task. Can be used to cancel this operation by
Kii.cancelTask(int)
-
refresh
public int refresh(@NonNull KiiUserCallBack callBack)
Asynchronous call forrefresh()
.
Background task will be initiated to execute the task.- Parameters:
callBack
- notifies event.- Returns:
- id of this task. Can be used to cancel this operation by
Kii.cancelTask(int)
-
resetPassword
@WorkerThread public static void resetPassword(@NonNull java.lang.String identifier) throws java.io.IOException, BadRequestException, UnauthorizedException, ForbiddenException, ConflictException, NotFoundException, UndefinedException
Reset the password of current login user.
Url for password reset will be sent to the specified identifier.
NOTE: This api access to server. Should not be executed in UI/Main thread.- Parameters:
identifier
- Email address which is binded to this user.- Throws:
java.io.IOException
- When network related error has occurred.UndefinedException
NotFoundException
ConflictException
ForbiddenException
BadRequestException
UnauthorizedException
- When user unauthorized error has happened.java.lang.IllegalArgumentException
- When given identifier is not valid email address.java.lang.IllegalStateException
- When KiiClient has not initialized.- See Also:
resetPassword(KiiUserCallBack, String)
-
resetPassword
@WorkerThread public static void resetPassword(@NonNull java.lang.String identifier, @NonNull KiiUser.NotificationMethod notificationMethod) throws ForbiddenException, BadRequestException, UndefinedException, java.io.IOException, ConflictException, NotFoundException, UnauthorizedException
Reset password of user specified by given identifier. This api won't execute login after reset.
NOTE: This api access to server. Should not be executed in UI/Main thread.- Parameters:
identifier
- should be valid email address, global phone number or user identifier obtained bygetID()
notificationMethod
- specify reset notification method. For details, please seeKiiUser.NotificationMethod
document. 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.)- Throws:
java.lang.IllegalArgumentException
- when identifier is null or empty or notificationMethod is null.java.lang.IllegalStateException
- when SDK has not initialized.ForbiddenException
BadRequestException
UndefinedException
java.io.IOException
ConflictException
NotFoundException
UnauthorizedException
-
resetPassword
public static int resetPassword(@NonNull KiiUserCallBack callBack, @NonNull java.lang.String identifier)
Asynchronous call forresetPassword(String)
.
Background task will be initiated to execute the task.- Parameters:
callBack
- notifies event.identifier
- Email address which is binded to this user.- Returns:
- id of this task. Can be used to cancel this operation by
Kii.cancelTask(int)
-
resetPassword
public static void resetPassword(@NonNull java.lang.String identifier, @NonNull KiiUser.NotificationMethod notificationMethod, @NonNull KiiCallback<java.lang.Void> callback)
Asynchronous call forresetPassword(String, com.kii.cloud.storage.KiiUser.NotificationMethod)
.
Background task will be initiated to execute the task.- Parameters:
identifier
- identifier of user.notificationMethod
- specify reset notification method. For details, please seeKiiUser.NotificationMethod
document.callback
- notifies event. null is not accepted.- Throws:
java.lang.IllegalArgumentException
- when callback is null.- See Also:
resetPassword(String, com.kii.cloud.storage.KiiUser.NotificationMethod)
-
completeResetPassword
public static void completeResetPassword(@NonNull java.lang.String identifier, @NonNull java.lang.String pinCode, @Nullable java.lang.String newPassword) throws java.io.IOException, ForbiddenException, BadRequestException, UndefinedException, ConflictException, NotFoundException, UnauthorizedException
Reset password with the PIN code in receipt SMS. AfterresetPassword(String, NotificationMethod)
is called withKiiUser.NotificationMethod.SMS_PIN
, SMS include the PIN code will be sent to the user's phone. User can set a new password for login with the PIN code. Need to calllogIn(String, String)
to login after the new password is determined.
NOTE: This api access to server. Should not be executed in UI/Main thread.- Parameters:
identifier
- should be valid email address, global phone number or user identifier obtained bygetID()
pinCode
- Received PIN code.newPassword
- 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.- Throws:
BadRequestException
- when newPassword is invalid.ForbiddenException
- when PIN code does not match with sent via SMS.ConflictException
- when the user does not have a verified phone number.UndefinedException
- when PIN code to reset password has expiredjava.io.IOException
NotFoundException
UnauthorizedException
-
completeResetPassword
public static void completeResetPassword(@NonNull java.lang.String identifier, @NonNull java.lang.String pinCode, @Nullable java.lang.String newPassword, @NonNull KiiCallback<java.lang.Void> callback)
Reset password with the PIN code in receipt SMS. Asynchronous version ofcompleteResetPassword(String, String, String)
. Background task will be initiated to execute the task.- Parameters:
identifier
- should be valid email address, global phone number or user identifier obtained bygetID()
pinCode
- Received PIN code.newPassword
- New password for login.callback
- Notifies events.
-
verifyPhone
@WorkerThread public void verifyPhone(@NonNull java.lang.String code) throws java.io.IOException, BadRequestException, UnauthorizedException, ForbiddenException, ConflictException, NotFoundException, UndefinedException
Verify this user's phone number with verification code in SMS sent by KiiCloud.
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 callrefresh()
and callgetPhone()
Before completion ofrefresh()
,getPhone()
returns cached phone number. It could be old phone number or null.
NOTE: This api access to server. Should not be executed in UI/Main thread.- Parameters:
code
- verification code in SMS sent by KiiCloud.- Throws:
java.io.IOException
- When network related error has happened.UndefinedException
NotFoundException
ConflictException
ForbiddenException
BadRequestException
UnauthorizedException
-
verifyPhone
public int verifyPhone(@NonNull KiiUserCallBack callBack, @NonNull java.lang.String code)
Asynchronous call forverifyPhone(String)
.
Background task will be initiated to execute the task.- Parameters:
callBack
- notified event.code
- verification code in SMS sent by KiiCloud.- Returns:
- id of this task. Can be used to cancel this operation by
Kii.cancelTask(int)
- See Also:
verifyPhone(String)
-
isPhoneVerified
public boolean isPhoneVerified()
Return true if Phone number is verified.- Returns:
- true if Phone number is verified.
- See Also:
verifyPhone(String)
-
isEmailVerified
public boolean isEmailVerified()
Return true if Email address is verified.
Note: Email verification is done from the verification email sent to the registered email.
Before call this method, callingrefresh()
is necessary to get the verification status.- Returns:
- true if Email address is verified.
-
isPseudoUser
public boolean isPseudoUser()
Return true if this instance is pseudo user.
If this method is not called for current login user, calling the
refresh()
or therefresh(KiiUserCallBack)
method is necessary to get a correct value.- Returns:
- true if this instance is pseudo user otherwise false.
-
getLinkedSocialAccounts
@NonNull public java.util.Map<KiiSocialNetworkConnector.Provider,SocialAccountInfo> getLinkedSocialAccounts()
Returns the social account info linked by this user. Refresh the user byrefresh()
orrefresh(KiiUserCallBack)
prior call the method. Otherwise, empty list will be returned.- Returns:
- Map
KiiSocialNetworkConnector.Provider
as key andSocialAccountInfo
as value.
-
isLinkedWithSocialProvider
public boolean isLinkedWithSocialProvider(@NonNull KiiSocialNetworkConnector.Provider provider)
Return true if this instance is linked by specified social provider. Refresh the user byrefresh()
orrefresh(KiiUserCallBack)
prior call the method. Otherwise, it always return false.- Parameters:
provider
- Social network to use.- Returns:
- true if this instance is linked by specified social provider otherwise false.
- Throws:
java.lang.IllegalArgumentException
- If specified provider is null.
-
userWithID
@NonNull public static KiiUser userWithID(@NonNull java.lang.String 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. After instantiation, callrefresh()
to fetch the properties.- Parameters:
userID
- Specify userID.- Returns:
- instance of KiiUser.
- Throws:
java.lang.IllegalArgumentException
- when passed userID is empty or null.- See Also:
getID()
-
createByUri
@NonNull public static KiiUser createByUri(@NonNull android.net.Uri uri)
Instantiate KiiUser from the Uri.
After instantiate, call {linkrefresh()
} to fetch properties.- Parameters:
uri
- Uri of the KiiUser to instantiate.- Returns:
- instance of KiiUser.
- Throws:
java.lang.IllegalArgumentException
- when passed uri is empty or null or invalid
-
getID
@Nullable public java.lang.String getID()
Returns the userID.- Returns:
- userID, null if the user has not saved to the cloud.
-
toUri
@Nullable public android.net.Uri toUri()
Returns URI of this KiiUser. The format is
kiicloud://users/{id of user}- Returns:
- URI of this KiiUser, null if KiiUser has not saved on cloud.
- See Also:
createByUri(Uri)
-
getCurrentUser
@Nullable public static KiiUser getCurrentUser()
Get current login user.- Returns:
- current login user. null if no user logged in.
- Throws:
java.lang.IllegalStateException
-Kii
has not initialized.
-
logOut
public static void logOut()
Logout current user.
Cached user information and token cleared.
-
isLoggedIn
public static boolean isLoggedIn()
Checks whether there is a user authenticated with the SDK.- Returns:
- true if there is user authenticated.
-
toString
@NonNull public java.lang.String toString()
Returns String representation of JSONObject get fromtoJSON()
- Overrides:
toString
in classjava.lang.Object
-
bucket
@NonNull public KiiBucket bucket(@NonNull java.lang.String bucketName)
Returns bucket belongs to this user.- Parameters:
bucketName
- name of the bucket.- Returns:
- KiiBucket belongs to this user.
- Throws:
java.lang.IllegalArgumentException
- when bucketName is not acceptable format. For details please refer toKiiBucket.isValidBucketName(String)
-
encryptedBucket
@NonNull public KiiEncryptedBucket encryptedBucket(@NonNull java.lang.String bucketName)
Returns the KiiEncryptedBucket instance belongs to this user- Parameters:
bucketName
- name of the bucket- Returns:
- encrypted bucket instance.
- Throws:
java.lang.IllegalArgumentException
- when bucketName is not acceptable format. For details please refer toKiiBucket.isValidBucketName(String)
-
changePhone
@WorkerThread public static void changePhone(@NonNull java.lang.String phoneNumber) throws java.io.IOException, BadRequestException, UnauthorizedException, ForbiddenException, ConflictException, NotFoundException, UndefinedException
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 bygetPendingPhone()
.
This API does not refresh the KiiUser automatically.
Please executerefresh()
before checking the value ofgetPhone()
orgetPendingPhone()
NOTE: This api access to server. Should not be executed in UI/Main thread.- Parameters:
phoneNumber
- New phone number.- Throws:
java.io.IOException
- When network related error has happened.UndefinedException
UnauthorizedException
NotFoundException
ConflictException
ForbiddenException
BadRequestException
java.lang.IllegalStateException
- There are no user logged in.java.lang.IllegalArgumentException
- when phoneNumber is not acceptable format. For details please refer toisValidPhone(String)
- See Also:
changePhone(KiiUserCallBack, String)
-
changePhone
public static int changePhone(@NonNull KiiUserCallBack callback, @NonNull java.lang.String phoneNumber)
- Parameters:
callback
- notifies events.phoneNumber
- new phone number.- Returns:
- task id of this operation. Can be used for cancel this operation.
- See Also:
Kii.cancelTask(int)
-
changeEmail
@WorkerThread public static void changeEmail(@NonNull java.lang.String email) throws java.io.IOException, BadRequestException, UnauthorizedException, ForbiddenException, ConflictException, NotFoundException, UndefinedException
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 bygetPendingEmail()
.
This API does not refresh the KiiUser automatically.
Please executerefresh()
before checking the value ofgetEmail()
orgetPendingEmail()
NOTE: This api access to server. Should not be executed in UI/Main thread.- Parameters:
email
- new email.- Throws:
java.io.IOException
- When network related error has happened.UndefinedException
UnauthorizedException
NotFoundException
ConflictException
ForbiddenException
BadRequestException
java.lang.IllegalStateException
- There are no user logged in.java.lang.IllegalArgumentException
- when email is not acceptable format. For details please refer toisValidEmail(String)
-
changeEmail
public static int changeEmail(@NonNull KiiUserCallBack callback, @NonNull java.lang.String email)
- Parameters:
callback
- notifies events.email
- new email.- Returns:
- task id of this operation. Can be used for cancel this operation.
- See Also:
Kii.cancelTask(int)
-
requestResendPhoneVerificationCode
@WorkerThread public static void requestResendPhoneVerificationCode() throws java.io.IOException, BadRequestException, UnauthorizedException, ForbiddenException, ConflictException, NotFoundException, UndefinedException
Request for re-send phone verification code to server. This operation is for login user.
NOTE: This api access to server. Should not be executed in UI/Main thread.- Throws:
java.io.IOException
- When network related error has happened.UndefinedException
UnauthorizedException
NotFoundException
ConflictException
ForbiddenException
BadRequestException
java.lang.IllegalStateException
- There are no user logged in.- See Also:
requestResendPhoneVerificationCode(KiiUserCallBack)
-
requestResendPhoneVerificationCode
public static int requestResendPhoneVerificationCode(@NonNull KiiUserCallBack callback)
Asynchronous call forrequestResendPhoneVerificationCode()
.
Background task will be initiated to execute the task.- Parameters:
callback
- notifies events.- Returns:
- task id of this operation. Can be used for cancel this operation.
- See Also:
Kii.cancelTask(int)
-
requestResendEmailVerification
@WorkerThread public static void requestResendEmailVerification() throws java.io.IOException, BadRequestException, UnauthorizedException, ForbiddenException, ConflictException, NotFoundException, UndefinedException
Request for re-send email verification code to server. This operation is for login user.
NOTE: This api access to server. Should not be executed in UI/Main thread.- Throws:
java.io.IOException
- When network related error has happened.UndefinedException
UnauthorizedException
NotFoundException
ConflictException
ForbiddenException
BadRequestException
java.lang.IllegalStateException
- There are no user logged in.- See Also:
requestResendEmailVerification(KiiUserCallBack)
-
requestResendEmailVerification
public static int requestResendEmailVerification(@NonNull KiiUserCallBack callback)
Asynchronous call forrequestResendEmailVerification()
.
Background task will be initiated to execute the task.- Parameters:
callback
- notifies events.- Returns:
- task id of this operation. Can be used for cancel this operation.
- See Also:
Kii.cancelTask(int)
-
isValidUserName
public static boolean isValidUserName(@Nullable java.lang.String username)
Checks whether the username is valid or not.
Valid username definition is:
- Not null.
- matches [a-zA-Z0-9-_\\.]{3,64}$
- Parameters:
username
- Name of the user.- Returns:
- true if valid otherwise false.
- Not null.
-
isValidDisplayName
public static boolean isValidDisplayName(@Nullable java.lang.String displayname)
Checks whether the display name is valid or not.
Valid display name definition is:- Not null or empty
- Between 1 to 50 characters.
- Parameters:
displayname
- Display name of the user.- Returns:
- true if valid otherwise false.
-
isValidCountry
public static boolean isValidCountry(@Nullable java.lang.String country)
Checks whether the country is valid or not.
Valid country definition is:- Not null or empty
- Matches ^[A-Z]{2}$
- Parameters:
country
- Country of the user.- Returns:
- true if valid otherwise false.
-
isValidEmail
public static boolean isValidEmail(@Nullable java.lang.String email)
Checks whether the email address is valid or not.
Valid email definition is:- Not null or empty
- Matches
Patterns.EMAIL_ADDRESS
- Parameters:
email
- Email of the user.- Returns:
- true if valid otherwise false.
-
isValidLocalPhone
public static boolean isValidLocalPhone(@Nullable java.lang.String phone)
Checks whether the phone number is valid or not.
Valid Phone number definition is:- Not null or empty
- Matches ^[0-9]
- Parameters:
phone
- Local Phone number of the user.- Returns:
- true if valid otherwise false.
-
isValidPhone
public static boolean isValidPhone(@Nullable java.lang.String phone)
Checks whether the phone number is valid or not.
This matches both international and local phone number.
Acceptable pattern is:- Matches [\\+]?[0-9.-]+
- Parameters:
phone
- Phone number of the user.- Returns:
- true if valid otherwise false.
-
isValidGlobalPhone
public static boolean isValidGlobalPhone(@Nullable java.lang.String phone)
Checks whether specified number is a valid international phone number.
Acceptable pattern is:- Matches ^[\\+][0-9.-]+
- Parameters:
phone
- Phone number of the user.- Returns:
- true if valid otherwise false.
-
isValidPassword
public static boolean isValidPassword(@Nullable java.lang.String password)
Checks whether the password is valid or not.
Password should be organized with ascii character exclude control characters.- Matches ^[\\u0020-\\u007E]{4,50}$
- Parameters:
password
- Password of the user.- Returns:
- true if valid otherwise false.
-
memberOfGroups
@WorkerThread @NonNull public java.util.List<KiiGroup> memberOfGroups() throws java.io.IOException, BadRequestException, UnauthorizedException, ForbiddenException, ConflictException, NotFoundException, UndefinedException
Returns the list of groups which the user is a member of. Group item in the list does not contain all the property of group. To get all the property from cloud, aKiiGroup.refresh()
is necessary.
NOTE: This api access to server. Should not be executed in UI/Main thread.- Returns:
- A list of the groups which the user is a member.If the user still not a member of any group, returns empty list.
- Throws:
java.io.IOException
- When network related error has happened.UndefinedException
NotFoundException
ConflictException
ForbiddenException
BadRequestException
UnauthorizedException
java.lang.IllegalStateException
- When SDK is not initialized OR user does not exist in the cloud.- See Also:
refresh(KiiUserCallBack)
,memberOfGroups(KiiUserCallBack)
-
memberOfGroups
public int memberOfGroups(@NonNull KiiUserCallBack callBack)
Asynchronous call formemberOfGroups()
.
Background task will be initiated to execute the task.- Parameters:
callBack
- notifies event.- Returns:
- id of this task. Can be used to cancel this operation by
Kii.cancelTask(int)
-
ownerOfGroups
@WorkerThread @NonNull public java.util.List<KiiGroup> ownerOfGroups() throws BadRequestException, UnauthorizedException, ForbiddenException, ConflictException, NotFoundException, UndefinedException, java.io.IOException
Returns the groups owned by this user. Group in the list does not contain all the property of group. To get all the property from cloud, aKiiGroup.refresh()
is necessary.
NOTE: This api access to server. Should not be executed in UI/Main thread.- Returns:
- List of the groups owned by this user.
- Throws:
java.io.IOException
- When network related error has happened.UndefinedException
NotFoundException
ConflictException
ForbiddenException
UnauthorizedException
BadRequestException
java.lang.IllegalStateException
- When SDK is not initialized OR user does not exist in the cloud.- See Also:
ownerOfGroups(KiiUserCallBack)
,KiiGroup.refresh()
,memberOfGroups()
-
ownerOfGroups
public int ownerOfGroups(@NonNull KiiUserCallBack callBack)
- Parameters:
callBack
-- Returns:
- id of this task. Can be used to cancel this operation by
Kii.cancelTask(int)
- See Also:
ownerOfGroups()
-
findUserByEmail
@WorkerThread @NonNull public static KiiUser findUserByEmail(@NonNull java.lang.String email) throws UnauthorizedException, ForbiddenException, NotFoundException, UndefinedException, java.io.IOException, BadRequestException
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, NotFoundException will be thrown.
Note: only the user name, display name property is exposed to others.
This api access to server. Should not be executed in UI/Main thread.- Parameters:
email
- find KiiUser who owns this email.
Don't add prefix of "EMAIL:" described in REST api documentation. SDK will take care of it.- Returns:
- KiiUser who have specified email.
- Throws:
UnauthorizedException
ForbiddenException
NotFoundException
UndefinedException
java.io.IOException
BadRequestException
-
findUserByPhone
@WorkerThread @NonNull public static KiiUser findUserByPhone(@NonNull java.lang.String phone) throws UnauthorizedException, ForbiddenException, NotFoundException, UndefinedException, java.io.IOException, BadRequestException
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, NotFoundException will be thrown.
Note: only the user name, display name property is exposed to others.
This api access to server. Should not be executed in UI/Main thread.- Parameters:
phone
- find KiiUser who owns this phone.
Don't add prefix of "PHONE:" described in REST api documentation. SDK will take care of it.- Returns:
- KiiUser who have specified phone.
- Throws:
UnauthorizedException
ForbiddenException
NotFoundException
UndefinedException
java.io.IOException
BadRequestException
-
findUserByUserName
@WorkerThread @NonNull public static KiiUser findUserByUserName(@NonNull java.lang.String username) throws UnauthorizedException, ForbiddenException, NotFoundException, UndefinedException, java.io.IOException, BadRequestException
Find registered KiiUser with the user name. If there are no user registers with the specified user name NotFoundException will be thrown.
Note: only the user name, display name property is exposed to others.
This api access to server. Should not be executed in UI/Main thread.- Parameters:
username
- find KiiUser who owns this username.
Don't add prefix of "LOGIN_NAME:" described in REST api documentation. SDK will take care of it.- Returns:
- KiiUser who have specified user name.
- Throws:
UnauthorizedException
ForbiddenException
NotFoundException
UndefinedException
java.io.IOException
BadRequestException
-
findUserByEmail
public static int findUserByEmail(@NonNull java.lang.String email, @NonNull KiiUserCallBack callback)
Asynchronous version offindUserByEmail(String)
. Background task will be initiated to execute the task.- Parameters:
email
- key of finding user.callback
- notifies event- Returns:
- id of this task. Can be used to cancel this operation by
Kii.cancelTask(int)
-
findUserByPhone
public static int findUserByPhone(@NonNull java.lang.String phone, @NonNull KiiUserCallBack callback)
Asynchronous version offindUserByPhone(String)
Background task will be initiated to execute the task.- Parameters:
phone
- key of finding usercallback
- notifies event.- Returns:
- id of this task. Can be used to cancel this operation by
Kii.cancelTask(int)
-
findUserByUserName
public static int findUserByUserName(@NonNull java.lang.String username, @NonNull KiiUserCallBack callback)
Asynchronous version offindUserByUserName(String)
Background task will be initiated to execute the task.- Parameters:
username
- key of finding user.callback
- notifies event.- Returns:
- id of this task. Can be used to cancel this operation by
Kii.cancelTask(int)
-
pushSubscription
@NonNull public KiiPushSubscription pushSubscription()
Get KiiPushSubscription instance of the user. The user will subscribe to the push service by using the returned instance.- Returns:
- KiiPushSubscription Instance of KiiPushSubscription.
- Throws:
java.lang.IllegalStateException
- Thrown if no user is logged-in.- See Also:
KiiPushSubscription
-
pushInstallation
@NonNull public static KiiPushInstallation pushInstallation()
Get KiiPushInstallation instance of current logged in user.
The installation will be created for production. (Same as callingpushInstallation(boolean)
with false.)
Note : You can control sending message to production/development installation, by specifying the flag when sending push message. Refer toKiiPushMessage.Builder.sendToDevelopment(boolean)
,KiiPushMessage.Builder.sendToProduction(boolean)
- Returns:
- KiiPushInstallation instance
- See Also:
KiiPushInstallation
,pushInstallation(boolean)
,KiiPushMessage.Builder.sendToProduction(boolean)
,KiiPushMessage.Builder.sendToDevelopment(boolean)
-
pushInstallation
@NonNull public static KiiPushInstallation pushInstallation(@NonNull KiiPushInstallation.PushBackend backend)
Get KiiPushInstallation instance of current logged in user with specified push backend.
The installation will be created for production. (Same as callingpushInstallation(KiiPushInstallation.PushBackend, boolean)
with false.)
Note : You can control sending message to production/development installation by specifying the flag when sending push message. Refer toKiiPushMessage.Builder.sendToDevelopment(boolean)
orKiiPushMessage.Builder.sendToProduction(boolean)
.- Parameters:
backend
- Push backend to operate installation.- Returns:
- KiiPushInstallation instance for specified push backend.
- See Also:
KiiPushInstallation
,KiiPushInstallation.PushBackend
,pushInstallation(KiiPushInstallation.PushBackend, boolean)
,KiiPushMessage.Builder.sendToProduction(boolean)
,KiiPushMessage.Builder.sendToDevelopment(boolean)
-
pushInstallation
@NonNull public static KiiPushInstallation pushInstallation(boolean development)
Get KiiPushInstallation instance of current logged in user.
development : true would be used for testing push before release application/new version. other wise, usepushInstallation()
.
Note : You can control sending message to production/ development installation, by specifying the flag when sending push message. Refer toKiiPushMessage.Builder.sendToDevelopment(boolean)
,KiiPushMessage.Builder.sendToProduction(boolean)
- Parameters:
development
- if true, the installation will be created for development.- Returns:
- KiiPushInstallation instance
- See Also:
KiiPushInstallation
,pushInstallation()
,KiiPushMessage.Builder.sendToProduction(boolean)
,KiiPushMessage.Builder.sendToDevelopment(boolean)
-
pushInstallation
@NonNull public static KiiPushInstallation pushInstallation(@NonNull KiiPushInstallation.PushBackend backend, boolean development)
Get KiiPushInstallation instance of current logged in user with specified push backend.
"development=true" would be used for testing push before release application/new version. Otherwise, usepushInstallation(KiiPushInstallation.PushBackend)
.
Note : You can control sending message to production/development installation by specifying the flag when sending push message. Refer toKiiPushMessage.Builder.sendToDevelopment(boolean)
orKiiPushMessage.Builder.sendToProduction(boolean)
.- Parameters:
backend
- Push backend to operate installation.development
- If true, the installation will be created for development. Otherwise, will be created for production.- Returns:
- KiiPushInstallation instance for specified push backend.
- See Also:
KiiPushInstallation.PushBackend
,KiiPushInstallation
,pushInstallation(KiiPushInstallation.PushBackend, boolean)
,KiiPushMessage.Builder.sendToProduction(boolean)
,KiiPushMessage.Builder.sendToDevelopment(boolean)
-
toJSON
@NonNull public org.json.JSONObject toJSON()
Returns JSON representation of this KiiUser. The JSONObject contains key/value from local cache. To get the latest key/value from cloud, callingrefresh()
is necessary prior calling this method. On refresh, it replaces the local cache with the cloud one.
For the key/value that is set byKiiBaseObject.set(String, byte[])
, JSONObject contains encoded(Base64) string of the value(byte[]). The properties of KiiUser will not be changed by operating returned JSONObject. NOTE: The returned JSONObject includes the key/value of arbitrary fields. The mapping of getter methods and keys of JSON are following.MethodName Key Getter returns null getUsername()
loginName org.json.JSONObject#NULL. getDisplayname()
displayName org.json.JSONObject#NULL. getEmail()
emailAddress org.json.JSONObject#NULL. getPhone()
phoneNumber org.json.JSONObject#NULL. getCountry()
country org.json.JSONObject#NULL. isEmailVerified()
emailAddressVerified - isPhoneVerified()
phoneNumberVerified - toUri()
_kiireserved_uri org.json.JSONObject#NULL. - Returns:
- JSONObject JSONObject represents this KiiUser.
-
topic
@NonNull public static KiiTopic topic(@NonNull java.lang.String name)
Get instance of user scope topic. The topic bound to current user.- Parameters:
name
-- Returns:
- KiiTopic bound to current user.
-
topicOfThisUser
@NonNull public KiiTopic topicOfThisUser(@NonNull java.lang.String name)
Get instance of user scope topic. The topic bound to this user.- Parameters:
name
-- Returns:
- KiiTopic bound to this user.
- Throws:
java.lang.IllegalStateException
- when the user has deleted or not registered in KiiCloud yet.
-
listTopics
@NonNull public KiiListResult<KiiTopic> listTopics() throws BadRequestException, UnauthorizedException, ForbiddenException, ConflictException, NotFoundException, UndefinedException, java.io.IOException
Returns the list of topics in this user scope.
NOTE: This api access to server. Should not be executed in UI/Main thread.- Returns:
- a list of the topics in this user scope.
Call
KiiListResult.hasNext()
to check if there are any more result. - Throws:
java.io.IOException
UnauthorizedException
ForbiddenException
BadRequestException
ConflictException
NotFoundException
UndefinedException
-
listTopics
@WorkerThread @NonNull public KiiListResult<KiiTopic> listTopics(@Nullable java.lang.String paginationKey) throws BadRequestException, UnauthorizedException, ForbiddenException, ConflictException, NotFoundException, UndefinedException, java.io.IOException
Returns the next page of list of topics in this user scope.
NOTE: This api access to server. Should not be executed in UI/Main thread.- Parameters:
paginationKey
- Specifies the pagination key that is obtained byKiiListResult.getPaginationKey()
. If specified null or empty, it's same as thelistTopics()
.- Returns:
- a list of the topics in this user scope.
- Throws:
java.io.IOException
UnauthorizedException
ForbiddenException
BadRequestException
ConflictException
NotFoundException
UndefinedException
-
listTopics
public void listTopics(@NonNull KiiCallback<KiiListResult<KiiTopic>> callback)
Asynchronous call forlistTopics()
. A background task will be initiated to execute the task.- Parameters:
callback
- notifies events.
-
listTopics
public void listTopics(@Nullable java.lang.String paginationKey, @NonNull KiiCallback<KiiListResult<KiiTopic>> callback)
Asynchronous call forlistTopics(String)
. A background task will be initiated to execute the task.- Parameters:
paginationKey
- Specifies the pagination key that is obtained byKiiListResult.getPaginationKey()
. If specified null or empty, it's same as thelistTopics(KiiCallback)
.callback
- notifies events.
-
equals
public boolean equals(@Nullable java.lang.Object user)
Return true when the specified KiiUser is in following conditions.- KiiUser ID is equal to this one.
- (If KiiUser does not have ID) KiiUser instance is equal to this one.
- Overrides:
equals
in classjava.lang.Object
- Parameters:
user
- KiiUser that will be compared to this.- Returns:
- If the given KiiUser is equal to this, false otherwise.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
describeContents
public int describeContents()
- Specified by:
describeContents
in interfaceandroid.os.Parcelable
-
writeToParcel
public void writeToParcel(@NonNull android.os.Parcel dest, int flags)
- Specified by:
writeToParcel
in interfaceandroid.os.Parcelable
-
getAccessTokenBundle
@Nullable public android.os.Bundle getAccessTokenBundle()
Return the access tokens in a bundle. Bundle contains:Key Type Value "access_token" String Required for accessing KiiCloud. "refresh_token" String Required for refreshing access token KiiCloud. "expires_at" Long Access token expiration time in milliseconds (Since January 1, 1970 00:00:00 UTC) - Returns:
- Access token bundle or null if user is not logged-in.
-
getThingOwnerID
@Nullable public java.lang.String getThingOwnerID()
Description copied from interface:KiiThingOwner
Get the ID of this owner with prefix.- Specified by:
getThingOwnerID
in interfaceKiiThingOwner
- Returns:
- user:{UserID} or group:{GroupID}
-
-