Unsubscribing from a Bucket

You can unsubscribe from a bucket to stop receiving a push notification when a change occurs in the bucket.

Here is the sample code for unsubscribing from a bucket.

  • // Instantiate the target bucket.
    var user = KiiUser.getCurrentUser();
    var bucket = user.bucketWithName("_target_bucket_");
    
    // Unsubscribe from the bucket.
    user.pushSubscription().unsubscribe(bucket).then(
      function(params) {
        var thePushSubscription = params[0];
        var theBucket = params[1];
        // Do something.
      }
    ).catch(
      function(error) {
        // Handle the error.
        var thePushSubscription = error.target;
        var errorString = error.message;
      }
    );
  • // Instantiate the target bucket.
    var user = KiiUser.getCurrentUser();
    var bucket = user.bucketWithName("_target_bucket_");
    
    // Unsubscribe from the bucket.
    user.pushSubscription().unsubscribe(bucket, {
      success: function(thePushSubscription, theBucket) {
        // Do something.
      },
      failure: function(errorString) {
        // Handle the error.
      }
    });

For more information, refer to the JSDoc.