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;

    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;

    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;
  • The Webcom parent for this location.

    Declaration

    Objective-C

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

    The Webcom reference for the location.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) WCWebcom *ref;
  • The Webcom root of the current namespace.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) WCWebcom *root;
  • 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;

    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;

    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;

    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;
  • Logouts the currently authenticated user

    Declaration

    Objective-C

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

    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;

    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;

    Parameters

    callback

    A block called when the session is resumed.

  • Unauthenticates the user

    Declaration

    Objective-C

    - (void)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;

    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;

    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;

    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;

    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;
  • Forces disconnection and disables the retry connection feature.

    Declaration

    Objective-C

    - (void)goOffline;
  • The WCOnDisconnect object attached to this Webcom location.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) WCOnDisconnect *onDisconnect;
  • Adds a new empty child at current location. Its key is automatically generated and is always unique.

    Declaration

    Objective-C

    - (WCWebcom *_Nullable)push;

    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;

    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;

    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;
  • Removes data at current location.

    Declaration

    Objective-C

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

    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;
  • Writes data at current location.

    Declaration

    Objective-C

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

    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;

    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;

    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;

    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;