Class KiiTopic
Represents a Topic object.
Defined in: KiiSDK.js.
Constructor Attributes | Constructor Name and Description |
---|---|
KiiTopic()
|
Method Attributes | Method Name and Description |
---|---|
acl()
Get ACL object of this topic.
|
|
deleteTopic(callbacks)
Delete the topic.
|
|
exists(callbacks)
Checks whether the topic already exists or not.
|
|
getName()
get name of this topic
|
|
save(callbacks)
Save this topic on Kii Cloud.
|
|
sendMessage(message, callbacks)
Send message to the topic.
|
Method Detail
{KiiACL}
acl()
Get ACL object of this topic.
Access to topic can be configured by adding/removing KiiACLEntry
to/from obtained acl object.
- Returns:
- {KiiACL} acl object of this topic.
{Promise}
deleteTopic(callbacks)
Delete the topic.
// example to use callbacks directly // assume topic is already instantiated. topic.deleteTopic({ success: function(topic) { // Delete topic succeeded. }, failure: function(error) { // Handle error. } }); // example to use Promise // assume topic is already instantiated. topic.deleteTopic().then( function(topic) { // Delete topic succeeded. }, function(error) { // Handle error. } );
- Parameters:
- {Object} callbacks Optional
- callback functions.
- {Function} callbacks.success
- callback called when operation succeeded.
argument is topic object. - {Function} callbacks.failure
- callback called when operation failed.
argument is Error object.
- Returns:
- {Promise} return promise object.
- fulfill callback function: function(theDeletedTopic). theDeletedTopic is a KiiTopic instance.
- reject callback function: function(error). error is an Error instance.
- error.target is the KiiTopic instance which this method was called on.
- error.message
{Promise}
exists(callbacks)
Checks whether the topic already exists or not.
// example to use callbacks directly // assume topic is already instantiated. topic.exists({ success: function(existed) { }, failure: function(error) { // Handle error. } }); // example to use Promise // assume topic is already instantiated. topic.exists().then( function(existed){ }, function(error){ // Handle error. });
- Parameters:
- {Object} callbacks Optional
- An object with callback methods defined
- {Method} callbacks.success
- callback called when operation succeeded.
argument is boolean. - {Method} callbacks.failure
- callback called when operation failed.
argument is error object.
- Returns:
- {Promise} return promise object.
- fulfill callback function: function(existed). true if the topic exists.
- reject callback function: function(error). error is an Error instance.
- error.target is the KiiTopic instance which this method was called on.
- error.message
{String}
getName()
get name of this topic
- Returns:
- {String} name of this topic.
{Promise}
save(callbacks)
Save this topic on Kii Cloud.
Note that only app admin can save application scope topic.
// example to use callbacks directly // assume topic is already instantiated. topic.save({ success: function(topic) { // Save topic succeeded. }, failure: function(error) { // Handle error. } }); // example to use Promise // assume topic is already instantiated. topic.save().then( function(topic) { // Save topic succeeded. }, function(error) { // Handle error. } );
- Parameters:
- {Object} callbacks Optional
- callback functions.
- {Function} callbacks.success
- callback called when operation succeeded.
argument is saved topic. - {Function} callbacks.failure
- callback called when operation failed.
argument is error object.
- Returns:
- {Promise} return promise object.
- fulfill callback function: function(theSavedTopic). theSavedTopic is a KiiTopic instance.
- reject callback function: function(error). error is an Error instance.
- error.target is the KiiTopic instance which this method was called on.
- error.message
{Promise}
sendMessage(message, callbacks)
Send message to the topic.
// example to use callbacks directly // assume topic is already instantiated. var contents = { message : "hello push!" }; var message = new KiiPushMessageBuilder(contents).build(); topic.sendMessage(message, { success: function(topic, message) { // Send message succeeded. }, failure: function(error) { // Handle error. } }); // example to use Promise // assume topic is already instantiated. var contents = { message : "hello push!" }; var message = new KiiPushMessageBuilder(contents).build(); topic.sendMessage(message).then( function(params) { // Send message succeeded. }, function(error) { // Handle error. } );
- Parameters:
- {Object} message
- to be sent.
- {Object} callbacks Optional
- callback functions.
- {Function} callbacks.success
- callback called when operation succeeded.
1st argument: topic object.
2nd argument: message object. - {Function} callbacks.failure
- callback called when operation failed.
argument is Error object.
- Returns:
- {Promise} return promise object.
- fulfill callback function: function(params). params is an Array instance.
- params[0] is the KiiTopic instance which this method was called on.
- params[1] is the message object to send.
- reject callback function: function(error). error is an Error instance.
- error.target is the KiiTopic instance which this method was called on.
- error.message
- fulfill callback function: function(params). params is an Array instance.