Inherits from NSObject
Conforms to KiiThingOwner
Declared in KiiUser.h

Overview

Contains user profile/account information and methods

The user class allows an application to generate a user, register them with the server and log them in during subsequent sessions. Since KiiUser is similar to KiiObject, the application can also set key/value pairs to this user.

Tasks

Properties

accessToken

The access token for the user - only available if the user is currently logged in.

@property (strong, readonly, nullable) NSString *accessToken

Discussion

The access token for the user - only available if the user is currently logged in.

Declared In

KiiUser.h

country

The country code associated with this user

@property (nonatomic, nullable) NSString *country

Discussion

The country code associated with this user

Declared In

KiiUser.h

created

The date the user was created on the server

@property (strong, readonly, nullable) NSDate *created

Discussion

The date the user was created on the server

Declared In

KiiUser.h

disabled

True if the user is disabled, false otherwise.

@property (readonly) BOOL disabled

Discussion

True if the user is disabled, false otherwise.

Call [KiiUser refreshWithBlock:], the [KiiUser refresh:withCallback:] or the [KiiUser refreshSynchronous:] prior calling this method to get correct status.

Declared In

KiiUser.h

displayName

Display name for this user. Cannot be used for logging a user in; is non-unique. Must be between 1 and 50 characters

@property (nonatomic, nullable) NSString *displayName

Discussion

Display name for this user. Cannot be used for logging a user in; is non-unique. Must be between 1 and 50 characters

Declared In

KiiUser.h

email

Email address to use for authentication or for display

@property (readonly, nullable) NSString *email

Discussion

Email address to use for authentication or for display

Declared In

KiiUser.h

emailVerified

Whether or not a user has validated their email address. This field is assigned by the server.

@property (readonly) BOOL emailVerified

Discussion

Whether or not a user has validated their email address. This field is assigned by the server.

Declared In

KiiUser.h

isPseudoUser

YES if this instance is pseudo user. otherwise NO.

@property (readonly) BOOL isPseudoUser

Discussion

YES if this instance is pseudo user. otherwise NO.

If this method is not called for current login user, calling the [KiiUser refreshWithBlock:], the [KiiUser refresh:withCallback:] or the [KiiUser refreshSynchronous:] method is necessary to get a correct value.

Declared In

KiiUser.h

linkedSocialAccounts

Gets the linked social providers. should be called before calling this API, otherwise it will always return empty dictionary. The keys of this Dictionary is KiiConnectorProvider encapsulated in a NSNumber.

@property (nonatomic, readonly) NSDictionary *linkedSocialAccounts

Return Value

A Dictionary of KiiSocialAccountInfo that is informations from the providers linked with this user.

Discussion

Gets the linked social providers. should be called before calling this API, otherwise it will always return empty dictionary. The keys of this Dictionary is KiiConnectorProvider encapsulated in a NSNumber.

Example:

    KiiSocialAccountInfo* facebookSocialInfo = [KiiUser currentUser].linkedSocialAccounts[@(kiiConnectorFacebook)];

Declared In

KiiUser.h

locale

Locale of the user. nil if the user registered without locale.

@property (nonatomic, nullable) LocaleContainer *locale

Discussion

Locale of the user. nil if the user registered without locale.

Declared In

KiiUser.h

modified

The date the user was last modified on the server

@property (strong, readonly, nullable) NSDate *modified

Discussion

The date the user was last modified on the server

Declared In

KiiUser.h

objectURI

Get a specifically formatted string referencing the user. The user must exist in the cloud (have a valid UUID).

@property (strong, readonly, nullable) NSString *objectURI

Discussion

Get a specifically formatted string referencing the user. The user must exist in the cloud (have a valid UUID).

Declared In

KiiUser.h

pendingEmail

Email address that has not been verified.

@property (readonly, nullable) NSString *pendingEmail

Discussion

Email address 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 email].
  • @see [KiiUser email], [KiiUser changeEmailSynchronous:withError:]

Declared In

KiiUser.h

pendingPhoneNumber

Phone number that has not been verified.

@property (readonly, nullable) NSString *pendingPhoneNumber

Discussion

Phone number that has not been verified.

  • When the user’s phone has been changed and phone verification is required in
  • your app configuration, New phone is stored as pending phone.
  • After the new phone has been verified, the number can be obtained by
  • [KiiUser phoneNumber].
  • @see [KiiUser phoneNumber], [KiiUser changePhoneSynchronous:withError:]

Declared In

KiiUser.h

phoneNumber

Phone number to use for authentication or for display

@property (readonly, nullable) NSString *phoneNumber

Discussion

Phone number to use for authentication or for display

Declared In

KiiUser.h

phoneVerified

Whether or not a user has validated their phone number. This field is assigned by the server.

@property (readonly) BOOL phoneVerified

Discussion

Whether or not a user has validated their phone number. This field is assigned by the server.

Declared In

KiiUser.h

userID

The unique ID of the KiiUser object, assigned by the server

@property (readonly, nullable) NSString *userID

Discussion

The unique ID of the KiiUser object, assigned by the server

Declared In

KiiUser.h

username

Username to use for authentication or for display. Must be between 3 and 64 characters, which can include alphanumeric characters as well as underscores ‘_’ and periods ‘.’

@property (readonly, nullable) NSString *username

Discussion

Username to use for authentication or for display. Must be between 3 and 64 characters, which can include alphanumeric characters as well as underscores ‘_’ and periods ‘.’

Declared In

KiiUser.h

uuid

The unique id of the KiiUser object, assigned by the server (Deprecated: Use [KiiUser userID] instead.)

@property (readonly, nullable) NSString *uuid

Discussion

The unique id of the KiiUser object, assigned by the server

Declared In

KiiUser.h

Class Methods

authenticate:withPassword:andBlock:

Asynchronously authenticates a user with the server

+ (void)authenticate:(NSString *)userIdentifier withPassword:(NSString *)password andBlock:(KiiUserBlock)block

Parameters

userIdentifier

Can be a username or a verified phone number or a verified email address

password

The user’s password. Password must be 4-50 characters and can include these characters: a-z, A-Z, 0-9, @, #, $, %, ^, and &.

block

The block to be called upon method completion. See example

Discussion

Asynchronously authenticates a user with the server

Authenticates a user with the server. This method is non-blocking. If successful, the user is cached inside SDK as current user, and accessible via [KiiUser currentUser]. 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 by [Kii setAccessTokenExpiration:]. User token can be get by [KiiUser accessToken]. From next time, it is possible to login with the access token until the token is expired.

 [KiiUser authenticate:@"myusername" withPassword:@"mypassword" andBlock:^(KiiUser *user, NSError *error) {
     if(error == nil) {
         NSLog(@"Authenticated user: %@", user);
     }
 }];

Declared In

KiiUser.h

authenticate:withPassword:andDelegate:andCallback:

Asynchronously authenticates a user with the server

+ (void)authenticate:(NSString *)userIdentifier withPassword:(NSString *)password andDelegate:(id)delegate andCallback:(SEL)callback

Parameters

userIdentifier

Can be a username or a verified phone number or a verified email address

password

The user’s password. Password must be 4-50 characters and can include these characters: a-z, A-Z, 0-9, @, #, $, %, ^, and &.

delegate

The object to make any callback requests to

callback

The callback method to be called when the request is completed. The callback method should have a signature similar to:

 - (void) authenticationComplete:(KiiUser*)user withError:(NSError*)error {

     // the request was successful
     if(error == nil) {
         // do something with the user
     }

     else {
         // there was a problem
     }
 }

Discussion

Asynchronously authenticates a user with the server

Authenticates a user with the server. This method is non-blocking. If successful, the user is cached inside SDK as current user, and accessible via [KiiUser currentUser]. 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 by [Kii setAccessTokenExpiration:]. User token can be get by [KiiUser accessToken]. From next time, it is possible to login with the access token until the token is expired.

Declared In

KiiUser.h

authenticateSynchronous:withPassword:andError:

Synchronously authenticates a user with the server

+ (nullable KiiUser *)authenticateSynchronous:(NSString *)userIdentifier withPassword:(NSString *)password andError:(NSError *_Nullable *_Nullable)error

Parameters

userIdentifier

Can be a username or a verified phone number or a verified email address

password

The user’s password. Password must be 4-50 characters and can include these characters: a-z, A-Z, 0-9, @, #, $, %, ^, and &.

error

used to return an error by reference (pass NULL if this is not desired). It is recommended to set an actual error object to get the error information.

Return Value

The KiiUser object that was authenticated. nil if failed to authenticate

Discussion

Synchronously authenticates a user with the server

Authenticates a user with the server. This method is blocking.

If successful, the user is cached inside SDK as current user, and accessible via [KiiUser currentUser]. 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 by [Kii setAccessTokenExpiration:]. User token can be get by [KiiUser accessToken]. From next time, it is possible to login with the access token until the token is expired.

Declared In

KiiUser.h

authenticateWithLocalPhoneNumber:andPassword:andCountryCode:andBlock:

Asynchronously authenticates a user with the server using local phone number, country code and password

+ (void)authenticateWithLocalPhoneNumber:(NSString *)phoneNumber andPassword:(NSString *)password andCountryCode:(NSString *)countryCode andBlock:(KiiUserBlock)block

Parameters

phoneNumber

local phone number, it must be numeric and at least 7 digit

password

The user’s password. Password must be 4-50 characters and can include these characters: a-z, A-Z, 0-9, @, #, $, %, ^, and &.

countryCode

2 digits phone country code, it must be capital letters

block

The block to be called upon method completion. See example

Discussion

Asynchronously authenticates a user with the server using local phone number, country code and password

Authenticates a user with the server. This method is non blocking. If successful, the user is cached inside SDK as current user, and accessible via [KiiUser currentUser]. 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 by [Kii setAccessTokenExpiration:]. User token can be get by [KiiUser accessToken]. From next time, it is possible to login with the access token until the token is expired.

Example: [KiiUser authenticateWithLocalPhoneNumber:@“9812345” andPassword:@“mypassword” andCountryCode:@“US” andBlock:^(KiiUser user, NSError error) { if(error == nil) { NSLog(@“Authenticated user: %@”, user); }

    }];

Declared In

KiiUser.h

authenticateWithLocalPhoneNumber:andPassword:andCountryCode:andDelegate:andCallback:

Asynchronously authenticates a user with the server using local phone number, country code and password

+ (void)authenticateWithLocalPhoneNumber:(NSString *)phoneNumber andPassword:(NSString *)password andCountryCode:(NSString *)countryCode andDelegate:(id)delegate andCallback:(SEL)callback

Parameters

phoneNumber

local phone number, it must be numeric and at least 7 digit

password

The user’s password. Password must be 4-50 characters and can include these characters: a-z, A-Z, 0-9, @, #, $, %, ^, and &.

countryCode

2 digits phone country code, it must be capital letters

delegate

The object to make any callback requests to

callback

The callback method to be called when the request is completed. The callback method should have a signature similar to:

- (void) authenticationComplete:(KiiUser*)user withError:(NSError*)error {

    // the request was successful
    if(error == nil) {
    // do something with the user
    }

    else {
    // there was a problem
    }
}

Discussion

Asynchronously authenticates a user with the server using local phone number, country code and password

Authenticates a user with the server. This method is non blocking. If successful, the user is cached inside SDK as current user, and accessible via [KiiUser currentUser]. 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 by [Kii setAccessTokenExpiration:]. User token can be get by [KiiUser accessToken]. From next time, it is possible to login with the access token until the token is expired.

Declared In

KiiUser.h

authenticateWithLocalPhoneNumberSynchronous:andPassword:andCountryCode:andError:

Synchronously authenticates a user with the server using local phone number, country code and password

+ (nullable KiiUser *)authenticateWithLocalPhoneNumberSynchronous:(NSString *)phoneNumber andPassword:(NSString *)password andCountryCode:(NSString *)countryCode andError:(NSError *_Nullable *_Nullable)error

Parameters

phoneNumber

local phone number, it must be numeric and at least 7 digit

password

The user’s password. Password must be 4-50 characters and can include these characters: a-z, A-Z, 0-9, @, #, $, %, ^, and &.

countryCode

2 digits phone country code, it must be capital letters

error

used to return an error by reference (pass NULL if this is not desired). It is recommended to set an actual error object to get the error information.

Return Value

The KiiUser object that was authenticated. nil if failed to authenticate

Discussion

Synchronously authenticates a user with the server using local phone number, country code and password

Authenticates a user with the server. This method is blocking.

Declared In

KiiUser.h

authenticateWithStoredCredentials:

Asynchronously authenticates a user with stored credentials from KeyChain.

+ (void)authenticateWithStoredCredentials:(KiiUserBlock)block

Parameters

block

The block to be called upon method completion. See example

Discussion

Asynchronously authenticates a user with stored credentials from KeyChain.

[KiiUser authenticateWithStoredCredentials:^(KiiUser *user, NSError *error) {
    if (error == nil) {
        // Succeeded.
    }
}];

Note: Follwing properties are stored/loaded.
You may need to fetch other properties by [KiiUser refreshWithBlock:] when you access to other properites.

  • username
  • displayName
  • email
  • emailVerified
  • pendingEmail
  • phoneNumber
  • phoneVerified
  • pendingPhone
  • country
  • refreshToken

Note: Prior to v2.2.2, KiiSDK stored user credentials with kSecAttrAccessibleWhenUnlock, so saving or loading user credentials would fail when device was unlocked. From v2.2.2, KiiSDK stores user credentials with kSecAttrAccessibleAfterFirstUnlock, which means as long as your app restarts after user first unlock device, it is possible to authenticate with stored user credentials, even the device is lockd.

Declared In

KiiUser.h

authenticateWithStoredCredentialsSynchronous:

Synchronously authenticates a user with stored credentials from KeyChain.

+ (nullable KiiUser *)authenticateWithStoredCredentialsSynchronous:(NSError *_Nullable *_Nullable)error

Parameters

error

used to return an error by reference (pass NULL if this is not desired). It is recommended to set an actual error object to get the error information.

Return Value

The KiiUser object that was authenticated. nil if failed to authenticate

Discussion

Synchronously authenticates a user with stored credentials from KeyChain.

Please confirm the details [KiiUser authenticateWithStoredCredentials:]

Declared In

KiiUser.h

authenticateWithToken:andBlock:

Asynchronously authenticates a user with the server using a valid access token

+ (void)authenticateWithToken:(NSString *)accessToken andBlock:(KiiUserBlock)block

Parameters

accessToken

A valid access token associated with the desired user

block

The block to be called upon method completion. See example

Discussion

Asynchronously authenticates a user with the server using a valid access token

Authenticates a user with the server. This method is non-blocking.

[KiiUser authenticateWithToken:@"my-user-token"
                      andBlock:^(KiiUser *user, NSError *error) {
    if(error == nil) {
        NSLog(@"Authenticated user: %@", user);
    }
 }];

Note: If successful, the user is cached inside SDK as current user, and accessible via [KiiUser currentUser]. Specified token is also cached and can be get by [KiiUser accessTokenDictionary] . Note that, token expiration time is not cached and set to [NSDate distantFuture]. If you want token expiration time also be cached, use [KiiUser authenticateWithTokenSynchronous:andExpiresAt:andError:] instead.

Declared In

KiiUser.h

authenticateWithToken:andDelegate:andCallback:

Asynchronously authenticates a user with the server using a valid access token

+ (void)authenticateWithToken:(NSString *)accessToken andDelegate:(id)delegate andCallback:(SEL)callback

Parameters

accessToken

A valid access token associated with the desired user

delegate

The object to make any callback requests to

callback

The callback method to be called when the request is completed. The callback method should have a signature similar to:

 - (void) authenticationComplete:(KiiUser*)user withError:(NSError*)error {

     // the request was successful
     if(error == nil) {
         // do something with the user
     }

     else {
         // there was a problem
     }
 }

Discussion

Asynchronously authenticates a user with the server using a valid access token

Authenticates a user with the server. This method is non-blocking. If the specified token is expired, authenticataiton will be failed. Authenticate the user again to renew the token.

Note: If successful, the user is cached inside SDK as current user, and accessible via [KiiUser currentUser]. Specified token is also cached and can be get by [KiiUser accessTokenDictionary] . Note that, token expiration time is not cached and set to [NSDate distantFuture]. If you want token expiration time also be cached, use [KiiUser authenticateWithTokenSynchronous:andExpiresAt:andError:] instead.

Declared In

KiiUser.h

authenticateWithToken:andExpiresAt:andBlock:

Asynchronously authenticates a user with the server using specified access token. This method is non-blocking.

+ (void)authenticateWithToken:(NSString *)accessToken andExpiresAt:(NSDate *)expiresAt andBlock:(KiiUserBlock)block

Parameters

accessToken

A valid access token associated with the desired user.

expiresAt

NSDate representation of accessToken expiration obtained from [KiiUser accessTokenDictionary].

block

The block to be called upon method completion. See example.

Discussion

Asynchronously authenticates a user with the server using specified access token. This method is non-blocking.

[KiiUser authenticateWithToken:@"my-user-token" 
                  andExpiresAt: expiresAt
                      andBlock:^(KiiUser *user, NSError *error) {
    if(error == nil) {
    NSLog(@"Authenticated user: %@", user);
    }
}];

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 accessTokenDictionary]. Also, if successful, the user is cached inside SDK as current user and accessible via [KiiUser currentUser].

Declared In

KiiUser.h

authenticateWithToken:expiresAt:refreshToken:block:

Asynchronously authenticates a user with the server using specified access token. This method is non-blocking.

+ (void)authenticateWithToken:(NSString *)accessToken expiresAt:(NSDate *)expiresAt refreshToken:(NSString *)refreshToken block:(KiiUserBlock)block

Parameters

accessToken

A valid access token associated with the desired user.

expiresAt

Access token expire time.

refreshToken

A valid refresh token for the user.

block

The block to be called upon method completion. See example.

Discussion

Asynchronously authenticates a user with the server using specified access token. This method is non-blocking.

[KiiUser authenticateWithToken:@“my-user-token” refreshToken: @“my-refresh-token” expiresAt: expiresAt block:^(KiiUser user, NSError error) { if(error == nil) { NSLog(@“Authenticated user: %@”, user); } }];

If successful, the user is cached inside SDK as current user and accessible via [KiiUser currentUser].

Declared In

KiiUser.h

authenticateWithTokenSynchronous:andError:

Synchronously authenticates a user with the server using a valid access token

+ (nullable KiiUser *)authenticateWithTokenSynchronous:(NSString *)accessToken andError:(NSError *_Nullable *_Nullable)error

Parameters

accessToken

A valid access token associated with the desired user

error

used to return an error by reference (pass NULL if this is not desired). It is recommended to set an actual error object to get the error information.

Return Value

The KiiUser object that was authenticated. nil if failed to authenticate

Discussion

Synchronously authenticates a user with the server using a valid access token

Authenticates a user with the server. This method is blocking. If the specified token is expired, authenticataiton will be failed. Authenticate the user again to renew the token.

Note: If successful, the user is cached inside SDK as current user, and accessible via [KiiUser currentUser]. Specified token is also cached and can be get by [KiiUser accessTokenDictionary] . Note that, token expiration time is not cached and set to [NSDate distantFuture]. If you want token expiration time also be cached, use [KiiUser authenticateWithTokenSynchronous:andExpiresAt:andError:] instead.

Declared In

KiiUser.h

authenticateWithTokenSynchronous:andExpiresAt:andError:

Synchronously authenticates a user with the server using specified access token. This method is blocking.

+ (nullable KiiUser *)authenticateWithTokenSynchronous:(NSString *)accessToken andExpiresAt:(NSDate *)expiresAt andError:(NSError *_Nullable *_Nullable)error

Parameters

accessToken

A valid access token associated with the desired user.

expiresAt

NSDate representation of accessToken expiration obtained from [KiiUser accessTokenDictionary].

error

used to return an error by reference (pass NULL if this is not desired). It is recommended to set an actual error object to get the error information.

Return Value

The KiiUser object that was authenticated. nil if failed to authenticate.

Discussion

Synchronously authenticates a user with the server using specified access token. This method is 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 accessTokenDictionary]. Also, if successful, the user is cached inside SDK as current user and accessible via [KiiUser currentUser].

Declared In

KiiUser.h

authenticateWithTokenSynchronous:expiresAt:refreshToken:error:

Synchronously authenticates a user with the server using specified access token and refresh token. This method is blocking.

+ (nullable KiiUser *)authenticateWithTokenSynchronous:(NSString *)accessToken expiresAt:(NSDate *)expiresAt refreshToken:(NSString *)refreshToken error:(NSError *_Nullable *_Nullable)error

Parameters

accessToken

A valid access token associated with the desired user.

expiresAt

Access token expire time.

refreshToken

A valid refresh token for the user.

error

used to return an error by reference (pass NULL if this is not desired). It is recommended to set an actual error object to get the error information.

Return Value

The KiiUser object that was authenticated. nil if failed to authenticate.

Discussion

Synchronously authenticates a user with the server using specified access token and refresh token. This method is blocking.

If successful, the user is cached inside SDK as current user and accessible via [KiiUser currentUser].

Declared In

KiiUser.h

completeResetPassword:pinCode:password:block:

Asynchronous version of [KiiUser completeResetPasswordSynchronous:pinCode:password:error]

+ (void)completeResetPassword:(NSString *)userIdentifier pinCode:(NSString *)pinCode password:(nullable NSString *)password block:(KiiErrorBlock)block

Parameters

userIdentifier

should be valid email address, global phone number or user identifier obtained by userID

pinCode

Received PIN code.

password

new password for login. If the ‘Password Reset Flow’ is set to ‘Generate Password’ in you app’s Security settings, It would be ignored and you can pass nil for this parameter. Otherwise valid password is required.

block

called upon method completion.

Discussion

Asynchronous version of [KiiUser completeResetPasswordSynchronous:pinCode:password:error]

Declared In

KiiUser.h

completeResetPasswordSynchronous:pinCode:password:error:

Reset password with the PIN code in receipt SMS. After <[KiiUser:resetPasswordSynchronous:notificationMethod:error]> is called with SMS_PIN notification method and completed, SMS includes PIN code will be sent to user’s phone.
User can set a new password for login with the PIN code. Please call authenticate method to login with the new password after the new password is determined.

+ (BOOL)completeResetPasswordSynchronous:(NSString *)userIdentifier pinCode:(NSString *)pinCode password:(nullable NSString *)password error:(NSError *_Nullable *_Nullable)error

Parameters

userIdentifier

should be valid email address, global phone number or user identifier obtained by userID

pinCode

Received PIN code.

password

new password for login. If the ‘Password Reset Flow’ is set to ‘Generate Password’ in you app’s Security settings, It would be ignored and you can pass nil for this parameter. In this case, password is generaged on Kii Cloud and sent to user’s phone. Otherwise valid password is required.

error

used to return an error by reference. Recommend to set nonnull error pointer reference to get the error information.

Return Value

YES if succeeded, NO otherwise.

Discussion

Reset password with the PIN code in receipt SMS. After <[KiiUser:resetPasswordSynchronous:notificationMethod:error]> is called with SMS_PIN notification method and completed, SMS includes PIN code will be sent to user’s phone.
User can set a new password for login with the PIN code. Please call authenticate method to login with the new password after the new password is determined.

Declared In

KiiUser.h

currentUser

Get the currently logged-in user

+ (nullable KiiUser *)currentUser

Return Value

A KiiUser object representing the current user, nil if no user is logged-in

Discussion

Get the currently logged-in user

Declared In

KiiUser.h

findUserByEmail:withBlock:

Find user by user e mail address asynchronously using block This is a non-blocking method. This method can only get user that has verified email.

+ (void)findUserByEmail:(NSString *)emailAddress withBlock:(KiiUserBlock)block

Parameters

emailAddress

The email address of user that want to be discovered. User can only find specific user from email that has been verified.

block

The block to be called upon method completion. See example

Discussion

Find user by user e mail address asynchronously using block This is a non-blocking method. This method can only get user that has verified email.

 [u findUserByEmail:@"email_to_found" withBlock:^(KiiUser *user, NSError *error) {
     if(error == nil) {
     NSLog(@"Found user: %@", user);
     }
 }];

Declared In

KiiUser.h

findUserByEmail:withDelegate:andCallback:

Find user by user e mail address asynchronously using delegate and callback This is a non-blocking method. This method can only get user that has verified email.

+ (void)findUserByEmail:(NSString *)emailAddress withDelegate:(id)delegate andCallback:(SEL)callback

Parameters

emailAddress

The email address of user that want to be discovered. User can only find specific user from email that has been verified.

delegate

The object to make any callback requests to

callback

The callback method to be called when the request is completed. The callback method should have a signature similar to:

 - (void) userFound:(KiiUser*)user withError:(NSError*)error {

     // the request was successful
     if(error == nil) {
     // do something with the user
     }

     else {
     // there was a problem
     }

 }

Discussion

Find user by user e mail address asynchronously using delegate and callback This is a non-blocking method. This method can only get user that has verified email.

Declared In

KiiUser.h

findUserByEmailSynchronous:withError:

Find user by user e mail address synchronously This is a blocking method. This method can only get user that has verified email.

+ (nullable KiiUser *)findUserByEmailSynchronous:(NSString *)emailAddress withError:(NSError *_Nullable *_Nullable)error

Parameters

emailAddress

The email address of user that want to be discovered. User can only find specific user from email that has been verified.

error

used to return an error by reference (pass NULL if this is not desired). It is recommended to set an actual error object to get the error information.

Discussion

Find user by user e mail address synchronously This is a blocking method. This method can only get user that has verified email.

Declared In

KiiUser.h

findUserByPhone:withBlock:

Find user by user phone asynchronously using block This is a non-blocking method. This method can only get user that has verified phone number.

+ (void)findUserByPhone:(NSString *)phoneNumber withBlock:(KiiUserBlock)block

Parameters

phoneNumber

the global phone number of user that want to be discovered. Do not pass local phone number, it is not supported. User can only find specific user from phone number that has been verified.

block

The block to be called upon method completion. See example

Discussion

Find user by user phone asynchronously using block This is a non-blocking method. This method can only get user that has verified phone number.

 [u findUserByPhone:@"phoneNumber_to_found" withBlock:^(KiiUser *user, NSError *error) {
     if(error == nil) {
     NSLog(@"Found user: %@", user);
     }
 }];

Declared In

KiiUser.h

findUserByPhone:withDelegate:andCallback:

Find user by user phone asynchronously using delegate and callback This is a non-blocking method. This method can only get user that has verified phone number.

+ (void)findUserByPhone:(NSString *)phoneNumber withDelegate:(id)delegate andCallback:(SEL)callback

Parameters

phoneNumber

The global phone number of user that want to be discovered. Do not pass local phone number, it is not supported. User can only find specific user from phone number that has been verified.

delegate

The object to make any callback requests to

callback

The callback method to be called when the request is completed. The callback method should have a signature similar to:

 - (void) userFound:(KiiUser*)user withError:(NSError*)error {

     // the request was successful
     if(error == nil) {
     // do something with the user
     }

     else {
     // there was a problem
     }

 }

Discussion

Find user by user phone asynchronously using delegate and callback This is a non-blocking method. This method can only get user that has verified phone number.

Declared In

KiiUser.h

findUserByPhoneSynchronous:withError:

Find user by user phone synchronously This is a blocking method. This method can only get user that has verified phone number.

+ (nullable KiiUser *)findUserByPhoneSynchronous:(NSString *)phoneNumber withError:(NSError *_Nullable *_Nullable)error

Parameters

phoneNumber

The global phone number of user that want to be discovered. Do not pass local phone number, it is not supported. User can only find specific user from phone number that has been verified.

error

used to return an error by reference (pass NULL if this is not desired). It is recommended to set an actual error object to get the error information.

Discussion

Find user by user phone synchronously This is a blocking method. This method can only get user that has verified phone number.

Declared In

KiiUser.h

findUserByUsername:withBlock:

Find user by username asynchronously using block This is a non-blocking method.

+ (void)findUserByUsername:(NSString *)username withBlock:(KiiUserBlock)block

Parameters

username

The username of user that want to be discovered

block

The block to be called upon method completion. See example

Discussion

Find user by username asynchronously using block This is a non-blocking method.

 [u findUserByUsername:@"user_to_found" withBlock:^(KiiUser *user, NSError *error) {
     if(error == nil) {
     NSLog(@"Found user: %@", user);
     }
 }];

Declared In

KiiUser.h

findUserByUsername:withDelegate:andCallback:

Find user by username asynchronously using delegate and callback This is a non-blocking method.

+ (void)findUserByUsername:(NSString *)username withDelegate:(id)delegate andCallback:(SEL)callback

Parameters

username

The username of user that want to be discovered

delegate

The object to make any callback requests to

callback

The callback method to be called when the request is completed. The callback method should have a signature similar to:

 - (void) userFound:(KiiUser*)user withError:(NSError*)error {

     // the request was successful
     if(error == nil) {
     // do something with the user
     }

     else {
     // there was a problem
     }

 }

Discussion

Find user by username asynchronously using delegate and callback This is a non-blocking method.

Declared In

KiiUser.h

findUserByUsernameSynchronous:withError:

Find user by username synchronously This is a blocking method.

+ (nullable KiiUser *)findUserByUsernameSynchronous:(NSString *)username withError:(NSError *_Nullable *_Nullable)error

Parameters

username

The username of user that want to be discovered

error

used to return an error by reference (pass NULL if this is not desired). It is recommended to set an actual error object to get the error information.

Discussion

Find user by username synchronously This is a blocking method.

Declared In

KiiUser.h

logOut

Logs the currently logged-in user out of the KiiSDK

+ (void)logOut

Discussion

Logs the currently logged-in user out of the KiiSDK

Declared In

KiiUser.h

loggedIn

Determines whether or not there is a KiiUser currently logged in

+ (BOOL)loggedIn

Return Value

TRUE if an authenticated user exists, FALSE otherwise

Discussion

Determines whether or not there is a KiiUser currently logged in

Declared In

KiiUser.h

registerAsPseudoUserSynchronousWithUserFields:error:

Register this user as pseudo user on KiiCloud.

+ (KiiUser *_Nullable)registerAsPseudoUserSynchronousWithUserFields:(nullable KiiUserFields *)userFields error:(NSError *_Nullable *_Nullable)error

Parameters

userFields

Optional. If nil is passed, display name, country and other custom field would not be set. To set those fields, create UserFields instance and pass to this API. fields which is not included in this instance

error

An NSError object, can be nil but not recommended.

Return Value

Registered new KiiUser.

Discussion

Register this user as pseudo user on KiiCloud.

This method registers this user as pseudo user on KiiCloud.

Declared In

KiiUser.h

registerAsPseudoUserWithUserFields:block:

Register this user as pseudo user on KiiCloud.

+ (void)registerAsPseudoUserWithUserFields:(nullable KiiUserFields *)userFields block:(KiiUserBlock)block

Parameters

userFields

Optional. If nil is passed, display name, country and other custom field would not be set. To set those fields, create UserFields instance and pass to this API. fields which is not included in this instance

block

The block to be called upon method completion. must not be nil. See example.

Discussion

Register this user as pseudo user on KiiCloud.

This method registers this user as pseudo user on KiiCloud.

custom fields will be gone. This method is non-blocking.

 [KiiUser registerAsPseudoUserWithUserFields:nil
                                       block:^(KiiUser *user, NSError *error) {
             if (error != nil) {
                 // fail to register. notify to user.
                 return;
             }
             // success to register.
         }
 ];

Exceptions

NSInvalidArgumentException

One or more arguments are invalid.

Declared In

KiiUser.h

resetPassword:notificationMethod:block:

Asynchronous version of resetPasswordSynchronous:notificationMethod:error:
Reset the password of user specified by given identifier.
This api does not execute login after reset.

+ (void)resetPassword:(NSString *)userIdentifier notificationMethod:(KiiNotificationMethod)notificationMethod block:(KiiErrorBlock)block

Parameters

userIdentifier

should be valid email address, global phone number or user identifier obtained by userID

notificationMethod

Specify reset notification method.
For details, please refer to KiiNotificationMethod 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.)

block

The block to be called upon method completion.

Discussion

Asynchronous version of resetPasswordSynchronous:notificationMethod:error:
Reset the password of user specified by given identifier.
This api does not execute login after reset.

Exceptions

NSInvalidArgumentException

notificationMethod arguments is not type of KiiNotificationMethod enum.

Declared In

KiiUser.h

resetPassword:withBlock:

Asynchronously reset a user’s password on the server.

+ (void)resetPassword:(NSString *)userIdentifier withBlock:(KiiErrorBlock)block

Parameters

userIdentifier

The email address which the account is associated with.

block

The block to be called upon method completion. See example.

Discussion

Asynchronously reset a user’s password on the server.

Reset a user’s password on the server. The user is determined by the specified email address that has already been associated with an account. Reset instructions will be sent to that email address. This method is non-blocking.

 [KiiUser resetPassword:@"myemail@address.com"
              withBlock:^(NSError *error) {
     if(error == nil) {
         NSLog(@"Reset user password!");
     }
 }];

Declared In

KiiUser.h

resetPassword:withDelegate:andCallback:

Asynchronously reset a user’s password on the server.

+ (void)resetPassword:(NSString *)userIdentifier withDelegate:(id)delegate andCallback:(SEL)callback

Parameters

userIdentifier

The email address which the account is associated with.

delegate

The object to make any callback requests to

callback

The callback method to be called when the request is completed. The callback method should have a signature similar to:

 - (void) passwordResetComplete:(NSError*)error {

     // the request was successful
     if(error == nil) {
         // do something with the user
     }

     else {
         // there was a problem
     }
 }

Discussion

Asynchronously reset a user’s password on the server.

Reset a user’s password on the server. The user is determined by the specified email address that has already been associated with an account. Reset instructions will be sent to that email address. This method is non-blocking.

Declared In

KiiUser.h

resetPasswordSynchronous:error:

Synchronously reset a user’s password on the server.

+ (BOOL)resetPasswordSynchronous:(NSString *)userIdentifier error:(NSError *_Nullable *_Nullable)error

Parameters

userIdentifier

The email address which the account is associated with.

error

used to return an error by reference (pass NULL if this is not desired). It is recommended to set an actual error object to get the error information.

Return Value

YES if succeeded, NO otherwise.

Discussion

Synchronously reset a user’s password on the server.

Reset a user’s password on the server.The user is determined by the specified email address that has already been associated with an account. Reset instructions will be sent to that email address. This method is blocking.

Declared In

KiiUser.h

resetPasswordSynchronous:notificationMethod:error:

Synchronously reset the user’s password.
Reset the password of user specified by given identifier.
This api does not execute login after reset.

+ (BOOL)resetPasswordSynchronous:(NSString *)userIdentifier notificationMethod:(KiiNotificationMethod)notificationMethod error:(NSError *_Nullable *_Nullable)error

Parameters

userIdentifier

should be valid email address, global phone number or user identifier obtained by userID

notificationMethod

Specify reset notification method.
For details, please refer to KiiNotificationMethod 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.)

error

used to return an error by reference (pass NULL if this is not desired). It is recommended to set an actual error object to get the error information.

Return Value

YES if succeeded, NO otherwise.

Discussion

Synchronously reset the user’s password.
Reset the password of user specified by given identifier.
This api does not execute login after reset.

Exceptions

NSInvalidArgumentException

notificationMethod arguments is not type of KiiNotificationMethod enum.

Declared In

KiiUser.h

resetPasswordSynchronous:withUserIdentifier:

+ (BOOL)resetPasswordSynchronous:(NSError *_Nullable *_Nullable)error withUserIdentifier:(NSString *)userIdentifier

Declared In

KiiUser.h

userWithEmailAddress:andPassword:

Create a user object to prepare for registration with credentials pre-filled

+ (KiiUser *)userWithEmailAddress:(NSString *)emailAddress andPassword:(NSString *)userPassword

Parameters

emailAddress

The user’s email address

userPassword

The user’s password. Password must be 4-50 characters and can include these characters: a-z, A-Z, 0-9, @, #, $, %, ^, and &.

Return Value

a working KiiUser object

Discussion

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.

Declared In

KiiUser.h

userWithEmailAddress:andPhoneNumber:andPassword:

Create a user object to prepare for registration with credentials pre-filled

+ (KiiUser *)userWithEmailAddress:(NSString *)emailAddress andPhoneNumber:(NSString *)phoneNumber andPassword:(NSString *)userPassword

Parameters

emailAddress

The user’s email address

phoneNumber

The user’s phone number

userPassword

The user’s password. Password must be 4-50 characters and can include these characters: a-z, A-Z, 0-9, @, #, $, %, ^, and &.

Return Value

a working KiiUser object

Discussion

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.

Declared In

KiiUser.h

userWithID:

Instantiate KiiUser that refers to existing user which has specified ID.

+ (KiiUser *)userWithID:(NSString *)userID

Parameters

userID

ID of the KiiUser to instantiate.

Return Value

instance of KiiUser.

Discussion

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, it should be ‘refreshed’ to fetch the properties from server.

Declared In

KiiUser.h

userWithPhoneNumber:andPassword:

Create a user object to prepare for registration with credentials pre-filled

+ (KiiUser *)userWithPhoneNumber:(NSString *)phoneNumber andPassword:(NSString *)userPassword

Parameters

phoneNumber

The user’s phone number

userPassword

The user’s password. Password must be 4-50 characters and can include these characters: a-z, A-Z, 0-9, @, #, $, %, ^, and &.

Return Value

a working KiiUser object

Discussion

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.

Declared In

KiiUser.h

userWithURI:

Create a KiiUser that references an existing user

+ (KiiUser *)userWithURI:(NSString *)uri

Parameters

uri

A user-specific URI

Return Value

a working KiiUser

Discussion

Create a KiiUser that references an existing user

Declared In

KiiUser.h

userWithUsername:andEmailAddress:andPassword:

Create a user object to prepare for registration with credentials pre-filled

+ (KiiUser *)userWithUsername:(NSString *)username andEmailAddress:(NSString *)emailAddress andPassword:(NSString *)userPassword

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 ‘.’

emailAddress

The user’s email address

userPassword

The user’s password. Password must be 4-50 characters and can include these characters: a-z, A-Z, 0-9, @, #, $, %, ^, and &.

Return Value

a working KiiUser object

Discussion

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.

Declared In

KiiUser.h

userWithUsername:andEmailAddress:andPhoneNumber:andPassword:

Create a user object to prepare for registration with credentials pre-filled

+ (KiiUser *)userWithUsername:(NSString *)username andEmailAddress:(NSString *)emailAddress andPhoneNumber:(NSString *)phoneNumber andPassword:(NSString *)userPassword

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 ‘.’

emailAddress

The user’s email address

phoneNumber

The user’s phone number

userPassword

The user’s password. Password must be 4-50 characters and can include these characters: a-z, A-Z, 0-9, @, #, $, %, ^, and &.

Return Value

a working KiiUser object

Discussion

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.

Declared In

KiiUser.h

userWithUsername:andPassword:

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. Custom fields can be added to it before it is registered or authenticated.

+ (KiiUser *)userWithUsername:(NSString *)userUsername andPassword:(NSString *)userPassword

Parameters

userUsername

The user’s desired username. Must be between 3 and 64 characters, which can include alphanumeric characters as well as underscores ‘_’, dashes ‘-’ and periods ‘.’

userPassword

The user’s password. Password must be 4-50 characters and can include these characters: a-z, A-Z, 0-9, @, #, $, %, ^, and &.

Return Value

a working KiiUser object

Discussion

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. Custom fields can be added to it before it is registered or authenticated.

Declared In

KiiUser.h

userWithUsername:andPhoneNumber:andPassword:

Create a user object to prepare for registration with credentials pre-filled

+ (KiiUser *)userWithUsername:(NSString *)username andPhoneNumber:(NSString *)phoneNumber andPassword:(NSString *)userPassword

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 ‘.’

phoneNumber

The user’s phone number

userPassword

The user’s password. Password must be 4-50 characters and can include these characters: a-z, A-Z, 0-9, @, #, $, %, ^, and &.

Return Value

a working KiiUser object

Discussion

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.

Declared In

KiiUser.h

Instance Methods

accessTokenDictionary

Return the access tokens in a dictionary.

- (nullable NSDictionary *)accessTokenDictionary

Return Value

Dictionary contains accessToken information (see table above),returns nil if user not logged in.

Discussion

Return the access tokens in a dictionary.

Dictionary contains following key/values.

Key Type Value
"access_token" NSString required for accessing KiiCloud
"expires_at" NSDate Access token expiration date time (Since January 1, 1970 00:00:00 UTC), or [NSDate distantFuture] if the session doesn't expire.
"refresh_token" NSString required for refreshing access token

Declared In

KiiUser.h

bucketWithName:

Get or create a bucket at the user level

- (KiiBucket *)bucketWithName:(NSString *)bucketName

Parameters

bucketName

The name of the bucket you’d like to use

Return Value

An instance of a working KiiBucket

Discussion

Get or create a bucket at the user level

Declared In

KiiUser.h

changeEmail:withBlock:

Updates the user’s email address on the server

- (void)changeEmail:(NSString *)newEmail withBlock:(KiiUserBlock)block

Parameters

newEmail

The new email address to change to

block

The block to be called upon method completion. See example

Discussion

Updates the user’s email address on the server

This is a non-blocking method.

 [u changeEmail:@"mynewemail@address.com" withBlock:^(KiiUser *user, NSError *error) {
     if(error == nil) {
         NSLog(@"Email changed for user: %@", user);
     }
 }];

Declared In

KiiUser.h

changeEmail:withDelegate:andCallback:

Updates the user’s email address on the server

- (void)changeEmail:(NSString *)newEmail withDelegate:(id)delegate andCallback:(SEL)callback

Parameters

newEmail

The new email address to change to

delegate

The object to make any callback requests to

callback

The callback method to be called when the request is completed. The callback method should have a signature similar to:

 - (void) emailChanged:(KiiUser*)user withError:(NSError*)error {

     // the request was successful
     if(error == nil) {
         // do something with the user
     }

     else {
         // there was a problem
     }

 }

*

Discussion

Updates the user’s email address on the server

This is a non-blocking method.

Declared In

KiiUser.h

changeEmailSynchronous:withError:

Updates the user’s email address on the server

- (BOOL)changeEmailSynchronous:(NSString *)newEmail withError:(NSError *_Nullable *_Nullable)error

Parameters

newEmail

The new email address to change to

error

used to return an error by reference (pass NULL if this is not desired). It is recommended to set an actual error object to get the error information.

Return Value

YES if succeeded, NO otherwise.

Discussion

Updates the user’s email address on the server

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 pendingEmail].
This API does not refresh the KiiUser automatically.
Please execute [KiiUser refresh:] before checking the value of [KiiUser email] or [KiiUser pendingEmail].
This is a blocking method.

Declared In

KiiUser.h

changePhone:withBlock:

Updates the user’s phone number on the server

- (void)changePhone:(NSString *)newPhoneNumber withBlock:(KiiUserBlock)block

Parameters

newPhoneNumber

The new phone number to change to

block

The block to be called upon method completion. See example

Discussion

Updates the user’s phone number on the server

This is a non-blocking method.

 [u changePhone:@"mynewphonenumber" withBlock:^(KiiUser *user, NSError *error) {
     if(error == nil) {
         NSLog(@"Phone changed for user: %@", user);
     }
 }];

Declared In

KiiUser.h

changePhone:withDelegate:andCallback:

Updates the user’s phone number on the server

- (void)changePhone:(NSString *)newPhoneNumber withDelegate:(id)delegate andCallback:(SEL)callback

Parameters

newPhoneNumber

The new phone number to change to

delegate

The object to make any callback requests to

callback

The callback method to be called when the request is completed. The callback method should have a signature similar to:

 - (void) phoneChanged:(KiiUser*)user withError:(NSError*)error {

     // the request was successful
     if(error == nil) {
         // do something with the user
     }

     else {
         // there was a problem
     }

 }

*

Discussion

Updates the user’s phone number on the server

This is a non-blocking method.

Declared In

KiiUser.h

changePhoneSynchronous:withError:

Updates the user’s phone number on the server

- (BOOL)changePhoneSynchronous:(NSString *)newPhoneNumber withError:(NSError *_Nullable *_Nullable)error

Parameters

newPhoneNumber

The new phone number to change to

error

used to return an error by reference (pass NULL if this is not desired). It is recommended to set an actual error object to get the error information.

Return Value

YES if succeeded, NO otherwise.

Discussion

Updates the user’s phone number on the server

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 pendingPhoneNumber].
This API does not refresh the KiiUser automatically.
Please execute {@link #refresh()} before checking the value of [KiiUser phoneNumber] or [KiiUser pendingPhoneNumber].
This is a blocking method.

Declared In

KiiUser.h

delete:withCallback:

Asynchronously deletes the user from the server

- (void)delete:(id)delegate withCallback:(SEL)callback

Parameters

delegate

The object to make any callback requests to

callback

The callback method to be called when the request is completed. The callback method should have a signature similar to:

 - (void) userDeleted:(KiiUser*)user withError:(NSError*)error {

     // the request was successful
     if(error == nil) {
         // do something with the object
     }

     else {
         // there was a problem
     }

 }

Discussion

Asynchronously deletes the user from the server

The user must exist on the server for this method to execute properly. This is a non-blocking method.

Declared In

KiiUser.h

deleteSynchronous:

Synchronously deletes the user from the server

- (BOOL)deleteSynchronous:(NSError *_Nullable *_Nullable)error

Parameters

error

used to return an error by reference (pass NULL if this is not desired). It is recommended to set an actual error object to get the error information.

Return Value

YES if succeeded, NO otherwise.

Discussion

Synchronously deletes the user from the server

The user must exist on the server for this method to execute properly. This is a blocking method.

Declared In

KiiUser.h

deleteWithBlock:

Asynchronously deletes the user from the server

- (void)deleteWithBlock:(KiiUserBlock)block

Parameters

block

The block to be called upon method completion. See example

Discussion

Asynchronously deletes the user from the server

The user must exist on the server for this method to execute properly. This is a non-blocking method.

 [u deleteWithBlock:^(KiiUser *user, NSError *error) {
     if(error == nil) {
         NSLog(@"User deleted!");
     }
 }];

Declared In

KiiUser.h

describe

Prints the contents of this user to log

- (void)describe

Discussion

Prints the contents of this user to log

For developer purposes only, this method prints the user in a readable format to the log for testing.

Declared In

KiiUser.h

encryptedBucketWithName:

Get or create an encrypted bucket at the user level.

- (KiiEncryptedBucket *)encryptedBucketWithName:(NSString *)bucketName

Parameters

bucketName

The name of the encrypted bucket you’d like to use.

Return Value

An instance of a working KiiEncryptedBucket

Discussion

Get or create an encrypted bucket at the user level.

Exceptions

NSInvalidArgumentException

when bucketName is not acceptable format. For details please refer to <[KiiBucket isValidBucketName:(NSString*) bucketName]>.

Declared In

KiiUser.h

getObjectForKey:

Gets the value associated with the given key

- (nullable id)getObjectForKey:(NSString *)key

Parameters

key

The key to retrieve

Return Value

An object if the key exists, nil otherwise

Discussion

Gets the value associated with the given key

Declared In

KiiUser.h

hasObject:

Checks to see if an object exists for a given key

- (BOOL)hasObject:(NSString *)key

Parameters

key

The key to check for existence

Return Value

True if the object exists, false otherwise.

Discussion

Checks to see if an object exists for a given key

Declared In

KiiUser.h

isEqual:

Return YES 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.

- (BOOL)isEqual:(nullable id)object

Parameters

object

KiiUser object that will be compared to this.

Return Value

YES if the given KiiUser is equal to this, NO otherwise.

Discussion

Return YES 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.

Declared In

KiiUser.h

isLinkedWithSocialProvider:

Checks the if this user is linked with specified social provider. should be called before calling this API, otherwise it will always return NO.

- (BOOL)isLinkedWithSocialProvider:(KiiConnectorProvider)provider

Parameters

provider

The provider to check

Return Value

YES if this user is linked with specified social provider, NO otherwise.

Discussion

Checks the if this user is linked with specified social provider. should be called before calling this API, otherwise it will always return NO.

Declared In

KiiUser.h

listTopics:

Returns the topics in this user scope asynchronously.

- (void)listTopics:(KiiListResultBlock)completion

Parameters

completion

The block to be called upon method completion, this is mandatory. See example.

Discussion

Returns the topics in this user scope asynchronously.

Receives a KiiListResult object representing list of topics. This is a non-blocking request.

[aUser listTopics:^(KiiListResult *topics, id callerObject, NSError *error){
   //at this scope, callerObject should be KiiUser instance
   NSLog(@"%@",callerObject);
   if(error == nil) {
        NSLog(@"Got Results: %@", topics);
        NSLog(@"Total topics: %@", topics.results.count);
        NSLog(@"Has Next: %@ next paginationKey: %@", topics.hasNext?@"Yes":@"No", topics.paginationKey);
        KiiTopic *firstTopic = topics.result.firstObject;
        if (firstTopic){
            NSLog(@"topic name :%@", firstTopic.name);
        }
   }
}];

Exceptions

NSInvalidArgumentException

if completion is nil.

Declared In

KiiUser.h

listTopics:block:

Returns the topics in this user scope asynchronously.

- (void)listTopics:(nullable NSString *)paginationKey block:(KiiListResultBlock)completion

Parameters

paginationKey

pagination key. If nil or empty value is specified, this API regards no paginationKey specified.

completion

The block to be called upon method completion, this is mandatory. See example.

Discussion

Returns the topics in this user scope asynchronously.

Receives a KiiListResult object representing list of topics. This is a non-blocking request.

[aUser listTopics:paginationKey block:^(KiiListResult *topics, id callerObject, NSError *error){
   //at this scope, callerObject should be KiiUser instance
   NSLog(@"%@",callerObject);
   if(error == nil) {
        NSLog(@"Got Results: %@", topics);
        NSLog(@"Total topics: %@", topics.results.count);
        NSLog(@"Has Next: %@ next paginationKey: %@", topics.hasNext?@"Yes":@"No", topics.paginationKey);
        KiiTopic *firstTopic = topics.result.firstObject;
        if (firstTopic){
            NSLog(@"topic name :%@", firstTopic.name);
        }
   }
}];

Exceptions

NSInvalidArgumentException

if completion is nil.

Declared In

KiiUser.h

listTopicsSynchronous:

Returns the topics in this user scope. This is blocking method.

- (nullable KiiListResult *)listTopicsSynchronous:(NSError *_Nullable *_Nullable)error

Parameters

error

used to return an error by reference (pass NULL if this is not desired). It is recommended to set an actual error object to get the error information.

Return Value

a KiiListResult object representing list of topics in this thing scope.

Discussion

Returns the topics in this user scope. This is blocking method.

Declared In

KiiUser.h

listTopicsSynchronous:error:

Returns the topics in this user scope. This is blocking method.

- (nullable KiiListResult *)listTopicsSynchronous:(nullable NSString *)paginationKey error:(NSError *_Nullable *_Nullable)error

Parameters

paginationKey

pagination key. If nil or empty value is specified, this API regards no paginationKey specified.

error

used to return an error by reference (pass NULL if this is not desired). It is recommended to set an actual error object to get the error information.

Return Value

a KiiListResult object representing list of topics in this user scope.

Discussion

Returns the topics in this user scope. This is blocking method.

Declared In

KiiUser.h

memberOfGroups:andCallback:

Asynchronously gets a list of groups which the user is a member of

- (void)memberOfGroups:(id)delegate andCallback:(SEL)callback

Parameters

delegate

The object to make any callback requests to

callback

The callback method to be called when the request is completed. The callback method should have a signature similar to:

 - (void) userIsMember:(KiiUser*)user ofGroups:(NSArray*)groups withError:(NSError*)error {

     // the request was successful
     if(error == nil) {

         // do something with the user's groups
         for(KiiGroup *g in groups) {
             // do something with the group
         }
     }

     else {
         // there was a problem
     }
 }

Discussion

Asynchronously gets a list of groups which the user is a member of

This is a non-blocking method.

Declared In

KiiUser.h

memberOfGroupsSynchronous:

Synchronously gets a list of groups which the user is a member of

- (nullable NSArray *)memberOfGroupsSynchronous:(NSError *_Nullable *_Nullable)error

Parameters

error

used to return an error by reference (pass NULL if this is not desired). It is recommended to set an actual error object to get the error information.

Return Value

An array of KiiGroup objects

Discussion

Synchronously gets a list of groups which the user is a member of

This is a blocking method.

Declared In

KiiUser.h

memberOfGroupsWithBlock:

Asynchronously gets a list of groups which the user is a member of

- (void)memberOfGroupsWithBlock:(KiiUserArrayBlock)block

Parameters

block

The block to be called upon method completion. See example

Discussion

Asynchronously gets a list of groups which the user is a member of

This is a non-blocking method.

 [u memberOfGroupsWithBlock:^(KiiUser *user, NSArray *results, NSError *error) {
     if(error == nil) {
         NSLog(@"User %@ is member of groups: %@", user, results);
     }
 }];

Declared In

KiiUser.h

ownerOfGroupsSynchronous:

Synchronously gets groups owned by this user. Group in the returned array does not contain all the property of group. To get all the property from cloud, KiiGroup refresh is necessary.This method is blocking.

- (nullable NSArray *)ownerOfGroupsSynchronous:(NSError *_Nullable *_Nullable)error

Parameters

error

used to return an error by reference (pass NULL if this is not desired). It is recommended to set an actual error object to get the error information.

Return Value

An NSArray Array of groups owned by the user.

Discussion

Synchronously gets groups owned by this user. Group in the returned array does not contain all the property of group. To get all the property from cloud, KiiGroup refresh is necessary.This method is blocking.

Declared In

KiiUser.h

ownerOfGroupsWithBlock:

Asynchronously gets the groups owned by this user. Group in the returned array does not contain all the property of group. To get all the property from cloud, KiiGroup refresh is necessary. This method is non-blocking.

- (void)ownerOfGroupsWithBlock:(KiiUserArrayBlock)block

Parameters

block

The block to be called upon method completion. See example.

Discussion

Asynchronously gets the groups owned by this user. Group in the returned array does not contain all the property of group. To get all the property from cloud, KiiGroup refresh is necessary. This method is non-blocking.

 [u ownerOfGroupsWithBlock:^(KiiUser *user, NSArray *results, NSError *error) {
     if(error == nil) {
         NSLog(@"User %@ is owner of groups: %@", user, results);
     }
 }];

Declared In

KiiUser.h

performRegistration:withCallback:

Asynchronously registers a user object with the server

- (void)performRegistration:(id)delegate withCallback:(SEL)callback

Parameters

delegate

The object to make any callback requests to

callback

The callback method to be called when the request is completed. The callback method should have a signature similar to:

 - (void) registrationComplete:(KiiUser*)user withError:(NSError*)error {

     // the request was successful
     if(error == nil) {
         // do something with the user
     }

     else {
         // there was a problem
     }
 }

Discussion

Asynchronously registers a user object with the server

Registers a user with the server. The user object must have an associated email/password combination. This method is non-blocking.

Declared In

KiiUser.h

performRegistrationSynchronous:

Synchronously registers a user object with the server

- (BOOL)performRegistrationSynchronous:(NSError *_Nullable *_Nullable)error

Parameters

error

used to return an error by reference (pass NULL if this is not desired). It is recommended to set an actual error object to get the error information.

Return Value

YES if succeeded, NO otherwise.

Discussion

Synchronously registers a user object with the server

Registers a user with the server. The user object must have an associated email/password combination. This method is blocking.

Declared In

KiiUser.h

performRegistrationWithBlock:

Asynchronously registers a user object with the server

- (void)performRegistrationWithBlock:(KiiUserBlock)block

Parameters

block

The block to be called upon method completion. See example

Discussion

Asynchronously registers a user object with the server

Registers a user with the server. The user object must have an associated email/password combination. This method is non-blocking. If the specified token is expired, authenticataiton will be failed. Authenticate the user again to renew the token.

 [u performRegistrationWithBlock:^(KiiUser *user, NSError *error) {
     if(error == nil) {
         NSLog(@"Registered user: %@", user);
     }
 }];

Declared In

KiiUser.h

pushSubscription

Get or create a push subscription for the user.

- (KiiPushSubscription *)pushSubscription

Return Value

An instance of a working KiiPushSubscription

Discussion

Get or create a push subscription for the user.

Declared In

KiiUser.h

putIdentityData:userFields:password:block:

Set identity data to pseudo user.

- (void)putIdentityData:(KiiIdentityData *)identityData userFields:(nullable KiiUserFields *)userFields password:(NSString *)password block:(KiiUserBlock)block

Parameters

identityData

Identity data must not be nil.

userFields

Optional. If nil is passed, display name, country and other custom field would not be update. To update those fields, create UserFields instance and pass to this API. fields which is not included in this instance

password

Password must not be nil. password must match a following regular expression: ^[a-zA-Z0-9]{4,64}$

block

The block to be called upon method completion. must not be nil. See example.

Discussion

Set identity data to pseudo user.

This user must be current user. password is mandatory and needs to provide at least one of login name, email address or phone number. Before call this method, calling refreshing method such as refreshWithBlock: is necessary to keep custom fields, otherwise custom fields will be gone. This method is non-blocking.

 [pseudoUser putIdentityData:identity
                    password:password
                       block:^(KiiUser *user, NSError *error) {
                       if (error != nil) {
                           // fail to putIdentity. notify to user.
                           return;
                       }
                       // success to putIdentity.
                   }
 ];

Note: This method is exclusive to logged-in pseudo user. If you use this method by non logged-in user, then this method fails and notifies NSError.

Exceptions

NSInvalidArgumentException

block is nil.

NSInternalInconsistencyException

raised when this user is not a pseudo user.

Declared In

KiiUser.h

putIdentityDataSynchronous:userFields:password:error:

Set identity data to pseudo user.

- (BOOL)putIdentityDataSynchronous:(KiiIdentityData *)identityData userFields:(nullable KiiUserFields *)userFields password:(NSString *)password error:(NSError *_Nullable *_Nullable)error

Parameters

identityData

Identity data must not be nil.

userFields

Optional. If nil is passed, display name, country and other custom field would not be update. To update those fields, create UserFields instance and pass to this API. fields which is not included in this instance

password

Password must not be nil. password must match a following regular expression: ^[a-zA-Z0-9]{4,64}$

error

An NSError object, can be nil but not recommended.

Return Value

YES if succeeded, NO otherwise.

Discussion

Set identity data to pseudo user.

This user must be current user. password is mandatory and needs to provide at least one of login name, email address or phone number. Before call this method, calling refreshing method such as refreshWithBlock: is necessary to keep custom fields, otherwise custom fields will be gone.

Note: This method is exclusive to logged-in pseudo user. If you use this method by non logged-in user, then this method fails and notifies NSError.

Exceptions

NSInvalidArgumentException

One or more arguments are invalid.

NSInternalInconsistencyException

Current user is not pseudo user.

Declared In

KiiUser.h

refresh:withCallback:

Asynchronously updates the local user’s data with the user data on the server

- (void)refresh:(id)delegate withCallback:(SEL)callback

Parameters

delegate

The object to make any callback requests to

callback

The callback method to be called when the request is completed. The callback method should have a signature similar to:

 - (void) userRefreshed:(KiiUser*)user withError:(NSError*)error {

     // the request was successful
     if(error == nil) {
         // do something with the user
     }

     else {
         // there was a problem
     }
 }

Discussion

Asynchronously 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.

Declared In

KiiUser.h

refreshSynchronous:

Synchronously updates the local user’s data with the user data on the server

- (BOOL)refreshSynchronous:(NSError *_Nullable *_Nullable)error

Parameters

error

used to return an error by reference (pass NULL if this is not desired). It is recommended to set an actual error object to get the error information.

Return Value

YES if succeeded, NO otherwise.

Discussion

Synchronously 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. This is a blocking method.

Declared In

KiiUser.h

refreshWithBlock:

Asynchronously updates the local user’s data with the user data on the server

- (void)refreshWithBlock:(KiiUserBlock)block

Parameters

block

The block to be called upon method completion. See example

Discussion

Asynchronously 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.

 [u refreshWithBlock:^(KiiUser *user, NSError *error) {
     if(error == nil) {
         NSLog(@"User refreshed: %@", user);
     }
 }];

Declared In

KiiUser.h

removeObjectForKey:

Removes a specific key/value pair from the object If the key exists, the key/value will be removed from the object.

- (void)removeObjectForKey:(NSString *)key

Parameters

key

The key of the key/value pair that will be removed.

Discussion

Removes a specific key/value pair from the object If the key exists, the key/value will be removed from the object.

Note: Since version 2.1.30, the behavior of this API has been changed. This method just removes the key-value pair from the local cache but no longer sets empty string (@“”) to the key and does not send specified key-value pair to the cloud when the update method ([KiiUser updateWithIdentityDataSynchronous:userFields:error:] etc.) is called. If you want to have same effect as previous, please execute setObject:forKey: with empty string (@“”) passed to the object explicitly.

Declared In

KiiUser.h

resendEmailVerification:andCallback:

Asynchronously resend the email verification

- (void)resendEmailVerification:(id)delegate andCallback:(SEL)callback

Parameters

delegate

The object to make any callback requests to

callback

The callback method to be called when the request is completed. The callback method should have a signature similar to:

 - (void) verificationCodeReSent:(KiiUser*)user withError:(NSError*)error {

     // the request was successful
     if(error == nil) {
         // do something with the user
     }

     else {
         // there was a problem
     }
 }

Discussion

Asynchronously resend the email verification

This method is used to resend the email verification for the currently logged in user. This is a non-blocking method.

Declared In

KiiUser.h

resendEmailVerificationSynchronous:

Synchronously resend the email verification

- (BOOL)resendEmailVerificationSynchronous:(NSError *_Nullable *_Nullable)error

Parameters

error

used to return an error by reference (pass NULL if this is not desired). It is recommended to set an actual error object to get the error information.

Return Value

YES if succeeded, NO otherwise.

Discussion

Synchronously resend the email verification

This method will re-send the email verification to the currently logged in user. This is a blocking method.

Declared In

KiiUser.h

resendEmailVerificationWithBlock:

Asynchronously resend the email verification

- (void)resendEmailVerificationWithBlock:(KiiUserBlock)block

Parameters

block

The block to be called upon method completion. See example

Discussion

Asynchronously resend the email verification

This method is used to resend the email verification for the currently logged in user. This is a non-blocking method.

 [u resendEmailVerificationWithBlock:^(KiiUser *user, NSError *error) {
     if(error == nil) {
         NSLog(@"Email verification resent!");
     }
 }];

Declared In

KiiUser.h

resendPhoneNumberVerification:andCallback:

Asynchronously resend the phone number verification

- (void)resendPhoneNumberVerification:(id)delegate andCallback:(SEL)callback

Parameters

delegate

The object to make any callback requests to

callback

The callback method to be called when the request is completed. The callback method should have a signature similar to:

 - (void) verificationCodeReSent:(KiiUser*)user withError:(NSError*)error {

     // the request was successful
     if(error == nil) {
         // do something with the user
     }

     else {
         // there was a problem
     }
 }

Discussion

Asynchronously resend the phone number verification

This method is used to resend the phone number verification for the currently logged in user. This is a non-blocking method.

Declared In

KiiUser.h

resendPhoneNumberVerificationSynchronous:

Synchronously resend the phone number verification

- (BOOL)resendPhoneNumberVerificationSynchronous:(NSError *_Nullable *_Nullable)error

Parameters

error

used to return an error by reference (pass NULL if this is not desired). It is recommended to set an actual error object to get the error information.

Return Value

YES if succeeded, NO otherwise.

Discussion

Synchronously resend the phone number verification

This method will re-send the SMS verification to the currently logged in user. This is a blocking method.

Declared In

KiiUser.h

resendPhoneNumberVerificationWithBlock:

Asynchronously resend the phone number verification

- (void)resendPhoneNumberVerificationWithBlock:(KiiUserBlock)block

Parameters

block

The block to be called upon method completion. See example

Discussion

Asynchronously resend the phone number verification

This method is used to re-send the SMS verification for the currently logged in user. This is a non-blocking method.

 [u resendPhoneNumberVerificationWithBlock:^(KiiUser *user, NSError *error) {
     if(error == nil) {
         NSLog(@"SMS verification resent!");
     }
 }];

Declared In

KiiUser.h

save:withCallback:

Asynchronously saves the latest user values to the server (Deprecated: This method is deprecated. Use [KiiUser updateWithIdentityData:userFields:block:] instead.)

- (void)save:(id)delegate withCallback:(SEL)callback

Parameters

delegate

The object to make any callback requests to

callback

The callback method to be called when the request is completed. The callback method should have a signature similar to:

 - (void) userSaved:(KiiUser*)user withError:(NSError*)error {

     // the request was successful
     if(error == nil) {
         // do something with the user
     }

     else {
         // there was a problem
     }
 }

Discussion

Asynchronously saves the latest user values to the server

The user must exist in order to make this method call. If the user does exist, the application-specific fields that have changed will be updated accordingly. This is a non-blocking method.

Declared In

KiiUser.h

saveSynchronous:

Synchronously saves the latest user values to the server (Deprecated: This method is deprecated. Use [KiiUser updateWithIdentityDataSynchronous:userFields:error:] instead.)

- (BOOL)saveSynchronous:(NSError *_Nullable *_Nullable)error

Parameters

error

used to return an error by reference (pass NULL if this is not desired). It is recommended to set an actual error object to get the error information.

Return Value

YES if succeeded, NO otherwise.

Discussion

Synchronously saves the latest user values to the server

The user must exist in order to make this method call. If the user does exist, the application-specific fields that have changed will be updated accordingly. This is a blocking method.

Declared In

KiiUser.h

saveWithBlock:

Asynchronously saves the latest user values to the server (Deprecated: This method is deprecated. Use [KiiUser updateWithIdentityData:userFields:block:] instead.)

- (void)saveWithBlock:(KiiUserBlock)block

Parameters

block

The block to be called upon method completion. See example

Discussion

Asynchronously saves the latest user values to the server

The user must exist in order to make this method call. If the user does exist, the application-specific fields that have changed will be updated accordingly. This is a non-blocking method.

 [u saveWithBlock:^(KiiUser *user, NSError *error) {
     if(error == nil) {
         NSLog(@"User saved: %@", user);
     }
 }];

Declared In

KiiUser.h

setObject:forKey:

Sets a key/value pair to a KiiUser

- (BOOL)setObject:(nullable id)object forKey:(NSString *)key

Parameters

object

The value to be set. Object must be of a JSON-encodable type (Ex: NSDictionary, NSArray, NSString, NSNumber, etc)

key

The key to set. The key must not begin with an underscore (_)

Return Value

True if the object was set, false otherwise.

Discussion

Sets a key/value pair to a KiiUser

If the key already exists, its value will be written over. If the object is of invalid type, it will return false and an NSError will be thrown (quietly). Accepted types are any JSON-encodable objects.

Declared In

KiiUser.h

topicWithName:

Get or create a Push notification topic at the user level

- (KiiTopic *)topicWithName:(NSString *)topicName

Parameters

topicName

The name of the topic you’d like to use. It has to match the pattern ^[A-Za-z0-9-]{1,64}$, that is letters, numbers, ‘-’ and ‘’ and non-multibyte characters with a length between 1 and 64 characters.

Return Value

An instance of a working KiiTopic

Discussion

Get or create a Push notification topic at the user level

Declared In

KiiUser.h

updatePassword:to:withBlock:

Asynchronously update a user’s password on the server

- (void)updatePassword:(NSString *)fromPassword to:(NSString *)toPassword withBlock:(KiiUserBlock)block

Parameters

fromPassword

The user’s current password

toPassword

The user’s desired password. Password must be 4-50 characters and can include these characters: a-z, A-Z, 0-9, @, #, $, %, ^, and &.

block

The block to be called upon method completion. See example

Discussion

Asynchronously 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. This method is non-blocking.

[user updatePassword:@"current_password" 
                  to:@"new_password"
           withBlock:^(KiiUser *user, NSError *error) {
    if(error == nil) {
        NSLog(@"Updated user password: %@", user);
     }
 }];

Declared In

KiiUser.h

updatePassword:to:withDelegate:andCallback:

Asynchronously update a user’s password on the server

- (void)updatePassword:(NSString *)fromPassword to:(NSString *)toPassword withDelegate:(id)delegate andCallback:(SEL)callback

Parameters

fromPassword

The user’s current password

toPassword

The user’s desired password. Password must be 4-50 characters and can include these characters: a-z, A-Z, 0-9, @, #, $, %, ^, and &.

delegate

The object to make any callback requests to

callback

The callback method to be called when the request is completed. The callback method should have a signature similar to:

 - (void) passwordUpdateComplete:(KiiUser*)user withError:(NSError*)error {

     // the request was successful
     if(error == nil) {
         // do something with the user
     }

     else {
         // there was a problem
     }
 }

Discussion

Asynchronously 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. This method is non-blocking.

Declared In

KiiUser.h

updatePasswordSynchronous:from:to:

- (BOOL)updatePasswordSynchronous:(NSError *_Nullable *_Nullable)error from:(NSString *)fromPassword to:(NSString *)toPassword

Declared In

KiiUser.h

updatePasswordSynchronous:newPassword:error:

Synchronously update a user’s password on the server

- (BOOL)updatePasswordSynchronous:(NSString *)password newPassword:(NSString *)newPassword error:(NSError *_Nullable *_Nullable)error

Parameters

password

The user’s current password

newPassword

The user’s desired password. Password must be 4-50 characters and can include these characters: a-z, A-Z, 0-9, @, #, $, %, ^, and &.

error

used to return an error by reference (pass NULL if this is not desired). It is recommended to set an actual error object to get the error information.

Return Value

YES if succeeded, NO otherwise.

Discussion

Synchronously update a user’s password on the server

Update a user’s password with the server. The password must be equal to the current password associated with the account in order to succeed. This method is blocking.

Declared In

KiiUser.h

updateWithIdentityData:userFields:block:

Asynchronously update user attributes.

- (void)updateWithIdentityData:(nullable KiiIdentityData *)identityData userFields:(nullable KiiUserFields *)userFields block:(KiiUserBlock)block

Parameters

identityData

Optional. If nil is passed, Identity data would not be updated and current value would be retained.

userFields

Optional. If nil is passed, display name, country and other custom field would not be set. To set those fields, create UserFields instance and pass to this API. fields which is not included in this instance

block

The block to be called upon method completion. See example. @exception NSInvalidArgumentException If this user is not pseudo user, raised when Both of identityData and userFields are nil. block should not be nil for both pseudo user and non pseudo user.

Discussion

Asynchronously update user attributes.

Notes:

  • This method is exclusive to logged-in user. If you use this method by non logged-in user, then this method fails and notifies NSError.

  • If this user is pseudo user and valid identityData given, execlution is failed and NSError is passed as KiiUserBlock argument.

  • Local modification done by and other setter methods in will be ignored. Please make sure to set new values in KiiUserFields.

  • At least one of identityData or userFields must be set.

    [pseudoUser updateWithIdentityData:identityData userFields:userFields block:^(KiiUser user, NSError error) { if (error != nil) { // fail to update. notify to user. return; } // success to update. } ];

Declared In

KiiUser.h

updateWithIdentityDataSynchronous:userFields:error:

Synchronously update user attributes.

- (BOOL)updateWithIdentityDataSynchronous:(nullable KiiIdentityData *)identityData userFields:(nullable KiiUserFields *)userFields error:(NSError *_Nullable *_Nullable)error

Parameters

identityData

Optional. If nil is passed, Identity data would not be updated and current value would be retained.

userFields

Optional. If nil is passed, display name, country and other custom field would not be set. To set those fields, create UserFields instance and pass to this API. fields which is not included in this instance

error

An NSError object, can be nil but not recommended.

Return Value

YES if succeeded, NO otherwise.

Discussion

Synchronously update user attributes.

Note: This method is exclusive to logged-in user. If you use this method by non logged-in user, then this method fails and notifies NSError.

Note: Local modification done by and other setter methods in will be ignored. Please make sure to set new values in KiiUserFields.

Note: At least one of identityData or userFields must be set.

Exceptions

NSInvalidArgumentException

If this user is pseudo user, raised when identityData is not nil. If this user is not pseudo user, raised when Both of identityData and userFields are nil.

Declared In

KiiUser.h

updateWithUserFields:block:

Asynchronously update user attributes.

- (void)updateWithUserFields:(KiiUserFields *)userFields block:(KiiUserBlock)block

Parameters

userFields

Mandatory. Must not be empty.

block

The block to be called upon method completion. See example.

Discussion

Asynchronously update user attributes.

Note: This method is exclusive to logged-in user. If you use this method by non logged-in user, then this method fails and notifies NSError.

Note: Local modification done by and other setter methods in will be ignored. Please make sure to set new values in KiiUserFields.

 [pseudoUser updateWithUserFields:userFields
                            block:^(KiiUser *user, NSError *error) {
                       if (error != nil) {
                           // fail to update. notify to user.
                           return;
                       }
                       // success to update.
                   }
 ];

Exceptions

NSInvalidArgumentException

userFields and/or block is nil.

Declared In

KiiUser.h

updateWithUserFieldsSynchronous:error:

Synchronously update user attributes.

- (BOOL)updateWithUserFieldsSynchronous:(KiiUserFields *)userFields error:(NSError *_Nullable *_Nullable)error

Parameters

userFields

Mandatory. Specifies which field would be updated.

error

An NSError object, can be nil but not recommended.

Return Value

YES if succeeded, NO otherwise.

Discussion

Synchronously update user attributes.

Note: This method is exclusive to logged-in user. If you use this method by non logged-in user, then this method fails and notifies NSError.

Declared In

KiiUser.h

verifyPhoneNumber:withBlock:

Asynchronously verify the current user’s phone number

- (void)verifyPhoneNumber:(NSString *)code withBlock:(KiiUserBlock)block

Parameters

code

The code which verifies the currently logged in user

block

The block to be called upon method completion. See example

Discussion

Asynchronously verify the current user’s phone number

This method is used to verify the phone number of the currently logged in user. This is a non-blocking method.

 [u verifyPhoneNumber:@"verification_code"
            withBlock:^(KiiUser *user, NSError *error) {
     if(error == nil) {
         NSLog(@"Verification complete!");
     }
 }];

Declared In

KiiUser.h

verifyPhoneNumber:withCode:

- (BOOL)verifyPhoneNumber:(NSError *_Nullable *_Nullable)error withCode:(NSString *)code

Declared In

KiiUser.h

verifyPhoneNumber:withDelegate:andCallback:

Asynchronously verify the current user’s phone number

- (void)verifyPhoneNumber:(NSString *)code withDelegate:(id)delegate andCallback:(SEL)callback

Parameters

code

The code which verifies the currently logged in user

delegate

The object to make any callback requests to

callback

The callback method to be called when the request is completed. The callback method should have a signature similar to:

Discussion

Asynchronously verify the current user’s phone number

This method is used to verify the phone number of the currently logged in user. This is a non-blocking method.

See Also

  • [KiiUser verifyPhoneNumber:withCode:]

     - (void) verificationComplete:(KiiUser*)user withError:(NSError*)error {
    
         // the request was successful
         if(error == nil) {
             // do something with the user
         }
    
         else {
             // there was a problem
         }
     }
    

Declared In

KiiUser.h

verifyPhoneNumberSynchronous:error:

Synchronously verify the current user’s phone number

- (BOOL)verifyPhoneNumberSynchronous:(NSString *)code error:(NSError *_Nullable *_Nullable)error

Parameters

code

The code which verifies the currently logged in user

error

used to return an error by reference (pass NULL if this is not desired). It is recommended to set an actual error object to get the error information.

Return Value

YES if succeeded, NO otherwise.

Discussion

Synchronously verify the current user’s phone number

This method is used to verify the phone number of the currently logged in user. This is a blocking method.

Verification code is sent from Kii Cloud through SMS 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 [KiiUser refreshSynchronous:] (or its asynchronuos version) before access to phoneNumber.
Before completion of [KiiUser refreshSynchronous:], value of phoneNumber is cached one. It could be old phone number or nil.

Declared In

KiiUser.h