WCWebcom

@interface WCWebcom : WCQuery

A WCWebcom instance represents a particular location in your namespace and can be used for reading or writing data to that location.

Reading data can be done with on(_:) and once(_:) methods and writing data can be done with set(_:), push(_:), update(_:) and remove(_:) methods

A WCWebcom instance is useful to read and write data at a defined location, specified by a URL parameter. You can also use specific methods and properties (for instance child(_:), parent, or root) to navigate into data structure.

  • Instantiates a Webcom location with the specified URL

    Declaration

    Objective-C

    - (nullable id)initWithURL:(nonnull NSString *)uri;

    Swift

    init?(url uri: String)

    Parameters

    uri

    The server URL

    Return Value

    The Webcom instance

  • Retrieves a Webcom instance at a given path.

    Declaration

    Objective-C

    - (nullable WCWebcom *)child:(nonnull NSString *)path;

    Swift

    func child(_ path: String) -> WCWebcom?

    Parameters

    path

    The relative path from the current location.

    Return Value

    The Webcom instance which targets the specified path.

  • The key name of Webcom instance.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) NSString *name;

    Swift

    var name: String? { get }
  • The Webcom parent for this location.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) WCWebcom *parent;

    Swift

    var parent: WCWebcom? { get }
  • ref

    The Webcom reference for the location.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) WCWebcom *ref;

    Swift

    var ref: WCWebcom? { get }
  • The Webcom root of the current namespace.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) WCWebcom *root;

    Swift

    var root: WCWebcom? { get }
  • Authenticates the user with a token or a Webcom secret.

    Declaration

    Objective-C

    - (void)authWithToken:(nonnull NSString *)token
               onComplete:(nonnull void (^)(NSError *_Nullable,
                                            WCAuthInfo *_Nullable))completeCallback;

    Swift

    func auth(withToken token: String, onComplete completeCallback: @escaping (Error?, WCAuthInfo?) -> Void)

    Parameters

    token

    The token or Webcom secret. Only use secret for server authentication. Be careful, it gives full control over namespace.

    completeCallback

    A block called once authentication is complete. On failure, the first argument contains the details of the error. The second argument contains information about the authentication.

  • Authenticates the user with a token or a Webcom secret.

    Declaration

    Objective-C

    - (void)authWithToken:(nonnull NSString *)token
               onComplete:(nonnull void (^)(NSError *_Nullable,
                                            WCAuthInfo *_Nullable))completeCallback
                 onCancel:(nullable void (^)(NSError *_Nullable))cancelCallback;

    Swift

    func auth(withToken token: String, onComplete completeCallback: @escaping (Error?, WCAuthInfo?) -> Void, onCancel cancelCallback: ((Error?) -> Void)? = nil)

    Parameters

    token

    The token or Webcom secret. Only use secret for server authentication. Be careful, it gives full control over namespace.

    completeCallback

    A block called once authentication is complete. On failure, the first argument contains error details. The second argument contains information about the authentication.

    cancelCallback

    A block called when authentication is cancelled because of expired token. The first argument contains error details.

  • Authenticates the user using an email and a password.

    Declaration

    Objective-C

    - (void)authWithMail:(nonnull NSString *)mail
             andPassword:(nonnull NSString *)password
           andRememberMe:(BOOL)rememberMe
              onComplete:(nonnull void (^)(NSError *_Nullable,
                                           WCAuthInfo *_Nullable))completeCallback;

    Swift

    func auth(withMail mail: String, andPassword password: String, andRememberMe rememberMe: Bool, onComplete completeCallback: @escaping (Error?, WCAuthInfo?) -> Void)

    Parameters

    mail

    The user’s email.

    password

    The user’s password.

    rememberMe

    Indicates if the session should last.

    completeCallback

    A block called once authentication is complete. On failure, the first argument contains error details. The second argument contains information about the authentication.

  • Logouts the currently authenticated user

    Declaration

    Objective-C

    - (void)logout;

    Swift

    func logout()
  • Logouts the currently authenticated user

    Declaration

    Objective-C

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

    Swift

    func logout(callback completeCallback: ((Error?) -> Void)? = nil)

    Parameters

    completeCallback

    A block called when the server finished logout. An error can be passed as the parameter if something went wrong.

  • Authenticates the user thanks to the OAuth 2.0 protocol.

    Declaration

    Objective-C

    - (void)oAuth2Provider:(nonnull NSString *)provider
                onComplete:
                    (nonnull void (^)(NSError *_Nullable,
                                      WCOAuth2UserInfoFromProvider *_Nullable))
                        completeCallback
                  onCancel:(nonnull void (^)(NSError *_Nonnull))cancelCallback;

    Swift

    func oAuth2Provider(_ provider: String, onComplete completeCallback: @escaping (Error?, WCOAuth2UserInfoFromProvider?) -> Void, onCancel cancelCallback: @escaping (Error) -> Void)

    Parameters

    provider

    The provider’s name (orange, google…). Let’s see the tutorial about oAuth2 to have the complete list and the accurate writing.

    completeCallback

    A block called once authentication is complete. On failure, the first argument contains error details. The second argument contains desired information about the access token returned by the provider.

    cancelCallback

    A block called once the user clicked on the ‘cancel’ button.

  • Resumes authentication

    Declaration

    Objective-C

    - (void)resumeWithCallback:(nonnull void (^)(NSError *_Nullable,
                                                 WCAuthInfo *_Nullable))callback;

    Swift

    func resume(callback: @escaping (Error?, WCAuthInfo?) -> Void)

    Parameters

    callback

    A block called when the session is resumed.

  • Unauthenticates the user

    Declaration

    Objective-C

    - (void)unauth;

    Swift

    func unauth()
  • Changes the password of an existing user using specified email and password.

    Declaration

    Objective-C

    - (void)changePasswordForUser:(nonnull NSString *)userMail
                  fromOldPassword:(nonnull NSString *)oldPassword
                    toNewPassword:(nonnull NSString *)newPassword
                       onComplete:(nonnull void (^)(NSError *_Nullable,
                                                    WCAuthInfo *_Nullable))
                                      completeCallback;

    Swift

    func changePassword(forUser userMail: String, fromOldPassword oldPassword: String, toNewPassword newPassword: String, onComplete completeCallback: @escaping (Error?, WCAuthInfo?) -> Void)

    Parameters

    userMail

    The user’s email.

    oldPassword

    The user’s old password.

    newPassword

    The user’s new password.

    completeCallback

    A block called when the user account has been changed. On failure, the first argument contains error details.

  • Creates a new user account using specified email and password.

    Declaration

    Objective-C

    - (void)createUser:(nonnull NSString *)userMail
          withPassword:(nonnull NSString *)password
            onComplete:(nonnull void (^)(NSError *_Nullable,
                                         WCAuthInfo *_Nullable))completeCallback;

    Swift

    func createUser(_ userMail: String, withPassword password: String, onComplete completeCallback: @escaping (Error?, WCAuthInfo?) -> Void)

    Parameters

    userMail

    The user’s email.

    password

    The user’s password.

    completeCallback

    A block called when the user account has been created. On failure, the first argument contains error details.

  • Removes an existing user account using specified email and password.

    Declaration

    Objective-C

    - (void)removeUser:(nonnull NSString *)userMail
          withPassword:(nonnull NSString *)password
            onComplete:(nonnull void (^)(NSError *_Nullable,
                                         WCAuthInfo *_Nullable))completeCallback;

    Swift

    func removeUser(_ userMail: String, withPassword password: String, onComplete completeCallback: @escaping (Error?, WCAuthInfo?) -> Void)

    Parameters

    userMail

    The user’s email.

    password

    The user’s password.

    completeCallback

    A block called when the user account has been deleted. On failure, the first argument contains error details.

  • Sends a password-reset email to the owner of the account. The email contains a token that may be used to authenticate and change the user’s password.

    Declaration

    Objective-C

    - (void)sendPasswordResetForUser:(nonnull NSString *)userMail
                          onComplete:(nonnull void (^)(NSError *_Nullable,
                                                       WCAuthInfo *_Nullable))
                                         completeCallback;

    Swift

    func sendPasswordReset(forUser userMail: String, onComplete completeCallback: @escaping (Error?, WCAuthInfo?) -> Void)

    Parameters

    userMail

    The user’s email.

    completeCallback

    A block called when the email has been sent. On failure, the first argument contains error details.

  • Forces reconnection and enables the retry connection feature.

    Declaration

    Objective-C

    - (void)goOnline;

    Swift

    func goOnline()
  • Forces disconnection and disables the retry connection feature.

    Declaration

    Objective-C

    - (void)goOffline;

    Swift

    func goOffline()
  • The WCOnDisconnect object attached to this Webcom location.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) WCOnDisconnect *onDisconnect;

    Swift

    var onDisconnect: WCOnDisconnect? { get }
  • Adds a new empty child at current location. Its key is automatically generated and is always unique.

    Declaration

    Objective-C

    - (WCWebcom *_Nullable)push;

    Swift

    func push() -> WCWebcom?

    Return Value

    The Webcom object for added location.

  • Adds a new child at current location. Its key is automatically generated and is always unique.

    Declaration

    Objective-C

    - (WCWebcom *_Nullable)push:(nullable NSObject *)value;

    Swift

    func push(_ value: NSObject?) -> WCWebcom?

    Parameters

    value

    The value of the new child.

    Return Value

    The Webcom object for added location.

  • Adds a new child at current location. Its key is automatically generated and is always unique.

    Declaration

    Objective-C

    - (WCWebcom *_Nullable)push:(nullable NSObject *)value
                     onComplete:
                         (nullable void (^)(NSError *_Nullable))completeCallback;

    Swift

    func push(_ value: NSObject?, onComplete completeCallback: ((Error?) -> Void)? = nil) -> WCWebcom?

    Parameters

    value

    The value of the new child.

    completeCallback

    A block called after synchronization with the server. An error can be passed as the first argument.

    Return Value

    The Webcom object for added location.

  • Removes data at current location.

    Declaration

    Objective-C

    - (void)remove;

    Swift

    func remove()
  • Removes data at current location.

    Declaration

    Objective-C

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

    Swift

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

    Parameters

    completeCallback

    A block called after synchronization with the server. An error can be passed as the first argument.

  • Writes empty data at current location.

    Declaration

    Objective-C

    - (void)set;

    Swift

    func set()
  • Writes data at current location.

    Declaration

    Objective-C

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

    Swift

    func set(_ value: NSObject?)

    Parameters

    value

    The new object value.

  • Writes data at current location.

    Declaration

    Objective-C

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

    Swift

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

    Parameters

    value

    The new object value.

    completeCallback

    A block called after synchronization with the server. An error can be passed as the first argument.

  • Updates data at current location.

    Declaration

    Objective-C

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

    Swift

    func update(_ value: NSObject)

    Parameters

    value

    The child to be updated or added

  • Updates data at current location.

    Declaration

    Objective-C

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

    Swift

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

    Parameters

    value

    The child to be updated or added

    completeCallback

    A block called after synchronization with the server. An error can be passed as the first argument.

  • Returns the absolute URL of the Webcom instance

    Declaration

    Objective-C

    - (nullable NSString *)toString;

    Swift

    func toString() -> String?

    Return Value

    The absolute URL