Kii Class Reference
Inherits from | NSObject |
Declared in | Kii.h |
Overview
The main SDK class
This class must be initialized on application launch using beginWithID:andKey:. This class also allows the application to make some high-level user calls and access some application-wide data at any time using static methods.
Tasks
-
+ beginWithID:andKey:
-
+ beginWithID:andKey:andSite:
-
+ setAccessTokenExpiration:
-
+ accessTokenExpiration
-
+ bucketWithName:
-
+ encryptedBucketWithName:
-
+ topicWithName:
-
+ getBuildNumber
-
+ getSDKVersion
-
+ groupWithName:
-
+ groupWithName:andMembers:
-
+ enableAPNSWithDevelopmentMode:andNotificationTypes:
-
+ setAPNSDeviceToken:
-
+ serverCodeEntry:
-
+ serverCodeEntry:withVersion:
-
+ serverCodeEntry:version:environment:
-
+ kiiAppsBaseURL
-
+ listTopicsSynchronous:
-
+ listTopicsSynchronous:error:
-
+ listTopics:
-
+ listTopics:block:
Class Methods
accessTokenExpiration
Returns access token lifetime. If access token lifetime has not set explicitly by setAccessTokenExpiration:, returns 0.
+ (long long)accessTokenExpiration
Return Value
access token lifetime in seconds.
Discussion
Returns access token lifetime. If access token lifetime has not set explicitly by setAccessTokenExpiration:, returns 0.
Exceptions
- throw
KiiIllegalStateException if Kii initialization is not called.
Declared In
Kii.h
beginWithID:andKey:
Initialize the Kii SDK
+ (void)beginWithID:(NSString *)appId andKey:(NSString *)appKey
Parameters
- appId
The application ID found in your Kii developer console
- appKey
The application key found in your Kii developer console
Discussion
Initialize the Kii SDK
Defaults to the US deployment. Should reside in applicationDidFinishLaunching:withResult: Meanwhile, Kii Analytics is initialized.
Declared In
Kii.h
beginWithID:andKey:andSite:
Initialize the Kii SDK
+ (void)beginWithID:(NSString *)appId andKey:(NSString *)appKey andSite:(KiiSite)kiiSite
Parameters
- appId
The application ID found in your Kii developer console
- appKey
The application key found in your Kii developer console
- kiiSite
One of the enumerator constants kiiSiteUS (United States), kiiSiteJP (Japan), kiiSiteCN3 (China), kiiSiteSG (Singapore) or kiiSiteEU (Europe) based on your desired location.
Discussion
Initialize the Kii SDK
Should reside in applicationDidFinishLaunching:withResult: If Kii has provided a custom URL, use this initializer to set it. Meanwhile, Kii Analytics is initialized.
Declared In
Kii.h
bucketWithName:
Get or create a bucket at the application 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 application level
Declared In
Kii.h
enableAPNSWithDevelopmentMode:andNotificationTypes:
Enable Kii APNS with APNS environment setting. (Deprecated: This method is deprecated. Use default iOS SDK [UIApplication registerForRemoteNotificationTypes] then call installation with [KiiPushInstallation installSynchronousWithDeviceToken:andDevelopmentMode:andError:])
+ (void)enableAPNSWithDevelopmentMode:(BOOL)isDevelopmentMode andNotificationTypes:(UIRemoteNotificationType)types
Parameters
- isDevelopmentMode
YES if APNS development environment mode or NO for production mode.
- types
of ui remote notification type.
Discussion
Enable Kii APNS with APNS environment setting.
Declared In
Kii.h
encryptedBucketWithName:
Get or create an encrypted bucket at the application 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 application level.
Exceptions
- NSInvalidArgumentException
when bucketName is not acceptable format. For details please refer to <[KiiBucket isValidBucketName:(NSString*) bucketName]>.
Declared In
Kii.h
getBuildNumber
Kii SDK Build Number
+ (NSString *)getBuildNumber
Return Value
An NSString object representing the current build number of the SDK
Discussion
Kii SDK Build Number
Declared In
Kii.h
getSDKVersion
Kii SDK Version Number
+ (NSString *)getSDKVersion
Return Value
An NSString object representing the current version number of the SDK
Discussion
Kii SDK Version Number
Declared In
Kii.h
groupWithName:
Creates a reference to a group with the given name
+ (KiiGroup *)groupWithName:(NSString *)groupName
Parameters
- groupName
An application-specific group name
Return Value
a working KiiGroup
Discussion
Creates a reference to a group with the given name
If the group already exists, it should be be ‘refreshed’ to fill the data from the server
Declared In
Kii.h
groupWithName:andMembers:
Creates a reference to a group with the given name with default members
+ (KiiGroup *)groupWithName:(NSString *)groupName andMembers:(nullable NSArray *)members
Parameters
- groupName
An application-specific group name
- members
An array of members to automatically add to the group upon creation
Return Value
a working KiiGroup
Discussion
Creates a reference to a group with the given name with default members
If the group already exists, it should be be ‘refreshed’ to fill the data from the server
Declared In
Kii.h
kiiAppsBaseURL
URL of KiiApps Server.
+ (NSString *)kiiAppsBaseURL
Return Value
A NSString object representing the URL of KiiApps Server.
Discussion
URL of KiiApps Server.
Declared In
Kii.h
listTopics:
Returns the topics in this App 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 App scope asynchronously.
Receives a KiiListResult object representing list of topics. This is a non-blocking request.
[Kii listTopics:^(KiiListResult *topics, id callerObject, NSError *error){
//at this scope, callerObject will always be nil.
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
Kii.h
listTopics:block:
Returns the topics in this app 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 app scope asynchronously.
Receives a KiiListResult object representing list of topics. This is a non-blocking request.
[Kii listTopics:paginationKey block:^(KiiListResult *topics, id callerObject, NSError *error){
//at this scope, callerObject will always be nil.
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
Kii.h
listTopicsSynchronous:
Returns the topics in this app 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 app scope.
Discussion
Returns the topics in this app scope. This is blocking method.
Declared In
Kii.h
listTopicsSynchronous:error:
Returns the topics in this app 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 app scope.
Discussion
Returns the topics in this app scope. This is blocking method.
Declared In
Kii.h
serverCodeEntry:
Create KiiServerCodeEntry instance with the given entry name.
+ (KiiServerCodeEntry *)serverCodeEntry:(NSString *)entryName
Parameters
- entryName
a specific entry name for this server code. Can not be nil and valid entryName pattern is “[a-zA-Z][_a-zA-Z0-9]*$”
Return Value
KiiServerCodeEntry instance.
Discussion
Create KiiServerCodeEntry instance with the given entry name.
Exceptions
- NSInvalidArgumentException
Thrown if given entryName is not valid.
Declared In
Kii.h
serverCodeEntry:version:environment:
Create KiiServerCodeEntry instance with the given entry name, version name and Node.js environment version.
+ (KiiServerCodeEntry *)serverCodeEntry:(NSString *)entryName version:(NSString *)version environment:(KiiServerCodeEnvironmentVersion)environmentVersion
Parameters
- entryName
a specific entry name for this server code. Can not be nil and valid entryName pattern is “[a-zA-Z][_a-zA-Z0-9]*$” .
- version
a string that represent version of the server code, must not nil or empty.
- environmentVersion
the version of Node.js to run.
Return Value
KiiServerCodeEntry instance.
Discussion
Create KiiServerCodeEntry instance with the given entry name, version name and Node.js environment version.
Exceptions
- NSInvalidArgumentException
Thrown if given entryName is not valid or version is nil/empty.
- NSInvalidArgumentException
Thrown if given version is nil or empty.
Declared In
Kii.h
serverCodeEntry:withVersion:
Create KiiServerCodeEntry instance with the given entry name and version name.
+ (KiiServerCodeEntry *)serverCodeEntry:(NSString *)entryName withVersion:(NSString *)version
Parameters
- entryName
a specific entry name for this server code. Can not be nil and valid entryName pattern is “[a-zA-Z][_a-zA-Z0-9]*$” .
- version
a string that represent version of the server code, must not nil or empty.
Return Value
KiiServerCodeEntry instance.
Discussion
Create KiiServerCodeEntry instance with the given entry name and version name.
Exceptions
- NSInvalidArgumentException
Thrown if given entryName is not valid or version is nil/empty.
- NSInvalidArgumentException
Thrown if given version is nil or empty.
Declared In
Kii.h
setAPNSDeviceToken:
Set APNS device token it is called on AppDelegate’s didRegisterForRemoteNotificationsWithDeviceToken (Deprecated: This method is deprecated. Use [KiiPushInstallation installSynchronousWithDeviceToken:andDevelopmentMode:andError:] instead.)
+ (void)setAPNSDeviceToken:(nullable NSData *)deviceToken
Parameters
- deviceToken
device token that is given by APNS server.
Discussion
Set APNS device token it is called on AppDelegate’s didRegisterForRemoteNotificationsWithDeviceToken
Declared In
Kii.h
setAccessTokenExpiration:
Set the access token lifetime in seconds.
+ (void)setAccessTokenExpiration:(long long)expiresIn
Parameters
- expiresIn
The life time of access token in seconds.
Discussion
Set the access token lifetime in seconds.
If you don’t call this method or call it with 0, token won’t be expired. Call this method if you like the access token to be expired after a certain period. Once called, token retrieved by each authentication will have the specified lifetime. Note that, it will not update the lifetime of token received prior calling this method. Once expired, you have to login again to renew the token.
Exceptions
- throw
NSInvalidArgumentException if expiresIn is negative value or greater than maximum long long.
- throw
KiiIllegalStateException if Kii initialization is not called.
Declared In
Kii.h
topicWithName:
Get a Topic at the application level Creation of App-scope topic is only supported by REST API calls, iOS SDK only has ability to get the app-scope topic object.
+ (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 a Topic at the application level Creation of App-scope topic is only supported by REST API calls, iOS SDK only has ability to get the app-scope topic object.
Declared In
Kii.h