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.
    KiiUser user = KiiUser.getCurrentUser();
    KiiBucket bucket = user.bucket("_target_bucket_");
    
    try {
      // Unsubscribe from the bucket.
      user.pushSubscription().unsubscribeBucket(bucket);
    } catch (IOException e) {
      // Handle the error.
    } catch (AppException e) {
      // Handle the error.
    }
  • // Instantiate the target bucket.
    KiiUser user = KiiUser.getCurrentUser();
    KiiBucket bucket = user.bucket("_target_bucket_");
    
    // Unsubscribe from the bucket.
    user.pushSubscription().unsubscribeBucket(bucket, new KiiPushCallBack() {
      @Override
      public void onUnSubscribeBucketCompleted(int taskId, KiiBucket target, Exception exception) {
        if (exception != null) {
          // Handle the error.
          return;
        }
      }
    });

For more information, refer to the Javadoc.