Bucket の購読確認

Bucket 購読の有無は次のように確認できます。

  • try {
      // Instantiate the target bucket.
      KiiBucket bucket = targetUser.bucket("_target_bucket_");
    
      // Check if the current user is subscribed to the bucket.
      KiiUser user = KiiUser.getCurrentUser();
      KiiPushSubscription ps = user.pushSubscription();
      boolean isSubscribed = ps.isSubscribed(bucket);
    
      if (isSubscribed) {
        // The current user is subscribed to the bucket.
      } else {
        // The current user is not subscribed to the bucket.
      }
    } catch (IOException ioe) {
      // Handle the error.
    } catch (AppException e) {
      // Handle the error.
    }
  • // Instantiate the target bucket.
    KiiBucket bucket = targetUser.bucket("_target_bucket_");
    
    // Check if the current user is subscribed to the bucket.
    KiiUser user = KiiUser.getCurrentUser();
    KiiPushSubscription ps = user.pushSubscription();
    ps.isSubscribed(bucket, new KiiPushCallBack() {
      @Override
      public void onCheckSubscriptionCompleted(int taskId, KiiSubscribable target, boolean isSubscribed, Exception exception) {
        if (exception != null) {
          // Handle the error.
          return;
        }
    
        if (isSubscribed) {
          // The current user is subscribed to the bucket.
        } else {
          // The current user is not subscribed to the bucket.
        }
      }
    });