Class Index | File Index

Classes


Class KiiPushSubscription

Represents a KiiPushSubscription.
Defined in: KiiSDK.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Method Summary
Method Attributes Method Name and Description
 
isSubscribed(target, callbacks)
Check subscription of bucket, topic.
 
subscribe(target, callbacks)
Subscribe to bucket or topic.
 
unsubscribe(target, callbacks)
Unsubscribe to bucket or topic.
Class Detail
KiiPushSubscription()
Method Detail
{Promise} isSubscribed(target, callbacks)
Check subscription of bucket, topic.
  // example to use callbacks directly
  var topic = Kii.topicWithName("myAppTopic");
  var user = KiiUser.getCurrentUser();
  user.pushSubscription().isSubscribed(topic, {
      success: function(subscription, topic, isSubscribed) {
          // Succeeded.
          if (isSubscribed) {
              // The topic is subscribed by current user.
          } else {
              // The topic is not subscribed by current user.
          }
      },
      failure: function(error) {
          // Handle error.
      }
  });
  
  // example to use Promise
  var topic = Kii.topicWithName("myAppTopic");
  var user = KiiUser.getCurrentUser();
  user.pushSubscription().isSubscribed(topic).then(
      function(params) {
          // Succeeded.
          var subscription = params[0];
          var topic = params[1];
          var isSubscribed = params[2];
          if (isSubscribed) {
              // The topic is subscribed by current user.
          } else {
              // The topic is not subscribed by current user.
          }
      },
      function(error) {
          // Handle error.
      }
  );
Parameters:
{Object} target
to check subscription. KiiBucket or KiiTopic instance.
{Object} callbacks Optional
object contains callback functions.
{Function} callbacks.success
callback called when operation succeeded.
1st argument: KiiPushSubscription object
2nd argument: target object
3rd argument: flag indicate whether the target object is subscirbed.
{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 a KiiPushSubscription instance.
    • params[1] is the KiiTopic instance to subscribe.
    • params[2] is Boolean value. true if subscirbed, otherwise false.
  • reject callback function: function(error). error is an Error instance.
    • error.target is a KiiPushSubscription instance.
    • error.message

{Promise} subscribe(target, callbacks)
Subscribe to bucket or topic.
  // example to use callbacks directly
  var topic = Kii.topicWithName("myAppTopic");
  var user = KiiUser.getCurrentUser();
  user.pushSubscription().subscribe(topic, {
      success: function(subscription, topic) {
          // Succeeded.
      },
      failure: function(error) {
          // Handle error.
      }
  });
  
  // example to use Promise
  var topic = Kii.topicWithName("myAppTopic");
  var user = KiiUser.getCurrentUser();
  user.pushSubscription().subscribe(topic).then(
      function(params) {
          var subscription = params[0];
          var topic = params[1];
          // Succeeded.
      },
      function(error) {
          // Handle error.
      }
  );
Parameters:
{Object} target
to be subscribed. KiiBucket or KiiTopic instance.
{Object} callbacks Optional
object contains callback functions.
{Function} callbacks.success
callback called when operation succeeded.
1st argument: KiiPushSubscription object
2nd argument: target 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 a KiiPushSubscription instance.
    • params[1] is the KiiTopic instance to subscribe.
  • reject callback function: function(error). error is an Error instance.
    • error.target is a KiiPushSubscription instance.
    • error.message

{Promise} unsubscribe(target, callbacks)
Unsubscribe to bucket or topic.
  // example to use callbacks directly
  var topic = Kii.topicWithName("myAppTopic");
  var user = KiiUser.getCurrentUser();
  user.pushSubscription().unsubscribe(topic, {
      success: function(subscription, topic) {
          // Succeeded.
      },
      failure: function(error) {
          // Handle error.
      }
  });
  
  // example to use Promise
  var topic = Kii.topicWithName("myAppTopic");
  var user = KiiUser.getCurrentUser();
  user.pushSubscription().unsubscribe(topic).then(
      function(params) {
          var subscription = params[0];
          var topic = params[1];
          // Succeeded.
      },
      function(error) {
          // Handle error.
      }
  );
Parameters:
{Object} target
to be unsubscribed. KiiBucket or KiiTopic instance.
{Object} callbacks Optional
object contains callback functions.
{Function} callbacks.success
callback called when operation succeeded.
1st argument: KiiPushSubscription object
2nd argument: target 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 a KiiPushSubscription instance.
    • params[1] is the KiiTopic instance to unsubscribe.
  • reject callback function: function(error). error is an Error instance.
    • error.target is a KiiPushSubscription instance.
    • error.message

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