トピックの購読解除

トピックの購読を止めることで、プッシュ通知を止めることができます。

以下に例を挙げます。

Swift:

  • // Assume that the current user is subscribed to the target topic and
    // the topic has been instantiated.
    
    do{
      // Unsubscribe from the topic.
      try KiiUser.current()!.pushSubscription().unsubscribeSynchronous(topic)
    } catch let error as NSError {
      // Handle the error.
      return
    }
  • // Assume that the current user is subscribed to the target topic and
    // the topic has been instantiated.
    
    // Unsubscribe from the topic.
    KiiUser.current()!.pushSubscription().unsubscribe(topic) { (subscription : KiiPushSubscription, error : Error?) -> Void in
      if error != nil {
        // Handle the error.
        return
      }
    }

Objective-C:

  • // Assume that the current user is subscribed to the target topic and
    // the topic has been instantiated.
    
    NSError *error = nil;
    
    // Unsubscribe from the topic.
    KiiPushSubscription *unsubscribe = [[KiiUser currentUser].pushSubscription unsubscribeSynchronous:topic
                                                                                                error:&error];
    if (error != nil) {
      // Handle the error.
      return;
    }
  • // Assume that the current user is subscribed to the target topic and
    // the topic has been instantiated.
    
    // Unsubscribe from the topic.
    [[KiiUser currentUser].pushSubscription unsubscribe:topic
                                                  block:^(KiiPushSubscription *subscription, NSError *error) {
      if (error != nil) {
        // Handle the error.
        return;
      }
    }];

対象トピックを指定して unsubscribeSynchronous:error: メソッドを実行してください。