Bucket 購読の有無は次のように確認できます。
Swift:
// Instantiate the target bucket. let bucket = Kii.bucket(withName: "_target_bucket_") do{ // Check if the current user is subscribed to the bucket. try KiiUser.current()!.pushSubscription().checkIsSubscribedSynchronous(bucket) }catch(let error as NSError){ print("The current user is not subscribed to the bucket."); } print("The current user is subscribed to the bucket.");
// Instantiate the target bucket. let bucket = Kii.bucket(withName: "_target_bucket_") // Check if the current user is subscribed to the bucket. KiiUser.current()!.pushSubscription().checkIsSubscribed(bucket) { (retBucket : KiiSubscribable , subscribed : Bool, error : Error?) -> Void in if error != nil { // Handle the error. return } if (subscribed) { print("The current user is subscribed to the bucket."); } else { print("The current user is not subscribed to the bucket."); } }
Objective-C:
NSError *error = nil; // Instantiate the target bucket. KiiBucket *bucket = [Kii bucketWithName:@"_target_bucket_"]; // Check if the current user is subscribed to the bucket. BOOL subscribed = [[KiiUser currentUser].pushSubscription checkIsSubscribedSynchronous:bucket error:&error]; if (subscribed) { NSLog(@"The current user is subscribed to the bucket."); } else { if (error.kiiHttpStatus == 404) { NSLog(@"The current user is not subscribed to the bucket."); } else { // Handle the error. return; } }
// Instantiate the target bucket. KiiBucket *bucket = [Kii bucketWithName:@"_target_bucket_"]; // Check if the current user is subscribed to the bucket. [[KiiUser currentUser].pushSubscription checkIsSubscribed:bucket block:^(id<KiiSubscribable> subscribable, BOOL subscribed, NSError *error) { if (subscribed) { NSLog(@"The current user is subscribed to the bucket."); } else { if (error.kiiHttpStatus == 404) { NSLog(@"The current user is not subscribed to the bucket."); } else { // Handle the error. return; } } }];