Bucket の購読解除

Bucket の講読を止めると、その Bucket で更新があってもプッシュ通知を受信しないようにできます。

Bucket の購読を解除する例を以下に挙げます。

Swift:

  • // Instantiate the target bucket.
    let bucket = Kii.bucket(withName: "_target_bucket_")
    
    do{
      // Unsubscribe from the bucket.
      try KiiUser.current()!.pushSubscription().unsubscribeSynchronous(bucket)
    } catch let error as NSError {
      // Handle the error.
      return
    }
  • // Instantiate the target bucket.
    let bucket = Kii.bucket(withName: "_target_bucket_")
    
    // Unsubscribe from the bucket.
    KiiUser.current()!.pushSubscription().unsubscribe(bucket, block: { (subscription : KiiPushSubscription, error : Error?) -> Void in
      if error != nil {
        // Handle the error.
        return
      }
    })

Objective-C:

  • NSError *error = nil;
    
    // Instantiate the target bucket.
    KiiBucket *bucket = [Kii bucketWithName:@"_target_bucket_"];
    
    // Unsubscribe from the bucket.
    [[KiiUser currentUser].pushSubscription unsubscribeSynchronous:bucket
                                                             error:&error];
    if (error != nil) {
      // Handle the error.
      return;
    }
  • // Instantiate the target bucket.
    KiiBucket *bucket = [Kii bucketWithName:@"_target_bucket_"];
    
    // Unsubscribe from the bucket.
    [[KiiUser currentUser].pushSubscription unsubscribe:bucket
                                                  block:^(KiiPushSubscription *subscription, NSError *error) {
      if (error != nil) {
        // Handle the error.
        return;
      }
    }];

より詳しい説明は appledoc をご確認ください。