WCOnDisconnect

@interface WCOnDisconnect : NSObject

An instance of WCOnDisconnect is useful to write and remove data if the user lost connection with the server. This can happen if there is a connection problem or if the app crashes.

Registered actions are executed only once. Register your actions again if you need to.

Managing presence is a common use case. You can prevent other friends if you are connected or not.

Set actions as soon as possible to catch early connection problems.

  • Cancels any action previously registered at the current location with the set(_:), update(_:) or remove(_:) methods.

    Declaration

    Objective-C

    - (void)cancel;

    Swift

    func cancel()
  • Cancels any action previously registered at the current location with the set(_:), update(_:) or remove(_:) methods.

    Declaration

    Objective-C

    - (void)cancelOnComplete:
        (nullable void (^)(NSError *_Nullable))completeCallback;

    Swift

    func cancel(onComplete completeCallback: ((Error?) -> Void)? = nil)

    Parameters

    completeCallback

    A block called when the server has cancelled the actions. An error can be passed as the parameter if something went wrong.

  • Removes the data at current location when a disconnection event occurs.

    Declaration

    Objective-C

    - (void)remove;

    Swift

    func remove()
  • Removes the data at current location when a disconnection event occurs.

    Declaration

    Objective-C

    - (void)removeOnComplete:
        (nullable void (^)(NSError *_Nullable))completeCallback;

    Swift

    func remove(onComplete completeCallback: ((Error?) -> Void)? = nil)

    Parameters

    completeCallback

    A block called when the server has registered the remove action. An error can be passed as the parameter if something went wrong.

  • Sets the data at current location when a disconnection event occurs.

    Declaration

    Objective-C

    - (void)set:(nullable NSObject *)object;

    Swift

    func set(_ object: NSObject?)

    Parameters

    object

    The data to be set.

  • Sets the data at current location when a disconnection event occurs.

    Declaration

    Objective-C

    - (void)set:(nullable NSObject *)object
        onComplete:(nullable void (^)(NSError *_Nullable))completeCallback;

    Swift

    func set(_ object: NSObject?, onComplete completeCallback: ((Error?) -> Void)? = nil)

    Parameters

    object

    The data to be set.

    completeCallback

    A block called when the server has registered the set action. An error can be passed as the parameter if something went wrong.

  • Updates the data at current location when a disconnection event occurs.

    Declaration

    Objective-C

    - (void)update:(nonnull NSObject *)object;

    Swift

    func update(_ object: NSObject)

    Parameters

    object

    The children to be added.

  • Updates the data at current location when a disconnection event occurs.

    Declaration

    Objective-C

    - (void)update:(nonnull NSObject *)object
        onComplete:(nullable void (^)(NSError *_Nullable))completeCallback;

    Swift

    func update(_ object: NSObject, onComplete completeCallback: ((Error?) -> Void)? = nil)

    Parameters

    object

    The children to be added.

    completeCallback

    A block called when the server has registered the update action. An error can be passed as the parameter if something went wrong.