Webcom

class Webcom : Query

A Webcom object is the entry point to the Webcom Datasync and Authentication services.

Important change over the legacy API: Initialization

Before you can instantiate a Webcom object, the SDK must have completed its initialization. To do so, you should register a Runnable to be called after the initialization is complete using the Webcom.onReady static method. Once any listener registered through this method has been called, all subsequent calls to the the are safe.

Examples

Java

Webcom.onReady(() -> {
Webcom ref = new Webcom("<your-app>");
(...)
});

Kotlin

Webcom.onReady {
val ref = Webcom("<your-app>")
(...)
}

Constructors

Webcom
Link copied to clipboard
fun Webcom(id: Id)
Webcom
Link copied to clipboard
fun Webcom(url: URL, options: WebcomOptions? = null)
Webcom
Link copied to clipboard
fun Webcom(url: String, options: WebcomOptions? = null)
Webcom
Link copied to clipboard
fun Webcom(application: WebcomApp, options: WebcomOptions? = null)

Creates a reference that represents the Webcom application.

Types

Companion
Link copied to clipboard
object Companion

Functions

addAccount
Link copied to clipboard
fun addAccount(provider: String, details: AuthDetails, callback: OnAuth)
fun addAccount(provider: String, details: AuthDetails, messageDetails: MessageDetails?, callback: OnAuth?)
addIdentity
Link copied to clipboard
fun addIdentity(provider: String, details: AuthDetails, callback: OnAuth)

Adds a new account to the app referred to by this Webcom instance. See Webcom.addIdentity.

fun addIdentity(provider: String, details: AuthDetails, messageDetails: MessageDetails?, callback: OnAuth?)

Adds a new account to the app referred to by this Webcom instance. The new account is associated to a new identity with the provider authentication method, whose details (typically msisdn, email or password) are provided by the details parameter. Currently, only 2 authentication methods are available to add an account: "password" (authentication with email and password) or "phone" (authentication with msisdn and one-time-password).

authAnonymously
Link copied to clipboard
fun authAnonymously(callback: OnAuth? = null)
authInternally
Link copied to clipboard
fun authInternally(provider: String, credentials: Credentials, callback: OnAuth? = null)
authWithCustomProvider
Link copied to clipboard
fun authWithCustomProvider(provider: String, token: String, callback: OnAuth? = null)
authWithOAuth
Link copied to clipboard
fun authWithOAuth(context: Context, provider: String, listener: OnAuthWithOAuth? = null, options: AuthOptions = AuthOptions.create())
fun authWithOAuth(context: Context, provider: String, options: AuthOptions, listener: OnAuthWithOAuth? = null, forcesWebView: Boolean = false)
authWithPassword
Link copied to clipboard
fun authWithPassword(email: String, password: String, callback: OnAuth? = null)
authWithPhone
Link copied to clipboard
fun authWithPhone(id: String, challenge: String, password: String)
fun authWithPhone(id: String, challenge: String, password: String, callback: OnAuth?)

Authenticates a user using her/his phone number. This method requires sending beforehand a one-time-password (OTP) to the user using the Webcom.sendOtp method. This operation is performed asynchronously. Upon authentication completion or failure, the registered authentication callbacks are called (see Webcom.registerAuthCallback).

authWithToken
Link copied to clipboard
fun authWithToken(token: String, callback: OnAuth?)
authWithWassup
Link copied to clipboard
fun authWithWassup(listener: OnAuth?)
fun authWithWassup(options: AuthOptions, listener: OnAuth? = null)
changePassword
Link copied to clipboard
fun changePassword(email: String, oldPassword: String, newPassword: String, callback: OnComplete?)
child
Link copied to clipboard
fun child(relativePath: String): Webcom

Returns a reference on the data node specified by a path relatively to the data node referred to by this instance.

cleanOfflineData
Link copied to clipboard
fun cleanOfflineData()
createUser
Link copied to clipboard
fun createUser(email: String, password: String, callback: OnAuth?)
endAt
Link copied to clipboard
fun endAt(name: String? = null): Query
equalTo
Link copied to clipboard
fun equalTo(name: String): Query
getCache
Link copied to clipboard
fun getCache(): DataSnapshot
getDatasyncState
Link copied to clipboard
fun getDatasyncState(): TreeLikeData

Retrieves the raw value of the current state of the Datasync service (low-level).

getUid
Link copied to clipboard
fun getUid(): Id
goOffline
Link copied to clipboard
fun goOffline()

Forces disconnection of the Datasync service associated with this instance from the Webcom back end.

goOnline
Link copied to clipboard
fun goOnline()

Forces reconnection of the Datasync service associated with this instance to the Webcom back end.

increment
Link copied to clipboard
fun increment(step: Number, startValue: Number = 0, onComplete: OnValue? = null)
internalRepresentation
Link copied to clipboard
fun internalRepresentation(): Any?
limit
Link copied to clipboard
fun limit(lim: Int): Query
logout
Link copied to clipboard
fun logout(onComplete: OnComplete? = null)
name
Link copied to clipboard
fun name(): String?
off
Link copied to clipboard
fun off()
fun off(eventType: Query.Event)
fun off(eventType: Query.Event, callback: OnQueryBase)
fun off(eventTypes: List<Query.Event>, callback: OnQueryBase)
offlineData
Link copied to clipboard
fun offlineData(): String
offPreservingOfflineData
Link copied to clipboard
fun offPreservingOfflineData()
fun offPreservingOfflineData(eventType: Query.Event)
fun offPreservingOfflineData(eventType: Query.Event, callback: OnQueryBase)
fun offPreservingOfflineData(eventTypes: List<Query.Event>, callback: OnQueryBase)
on
Link copied to clipboard
fun on(eventType: Query.Event, callback: OnQueryBase)
fun on(eventTypes: List<Query.Event>, callback: OnQueryBase)
once
Link copied to clipboard
fun once(eventType: Query.Event, callback: OnQueryBase)
onDisconnect
Link copied to clipboard
fun onDisconnect(): OnDisconnect
parent
Link copied to clipboard
fun parent(): Webcom?

Returns a reference on the parent data node wrt. to the data node referred to by this instance.

path
Link copied to clipboard
fun path(): String
persist
Link copied to clipboard
fun persist()
push
Link copied to clipboard
fun push(): Webcom

Returns a reference on a child data node with a unique key.

fun push(data: Any?, onComplete: OnComplete? = null): Webcom

Write some given data under a new child data node with a unique key.

pushIdToDateTime
Link copied to clipboard
fun pushIdToDateTime(id: String): Long

Extract the timestamp from a key id generated by the push method.

ref
Link copied to clipboard
fun ref(): Webcom
registerAuthCallback
Link copied to clipboard
fun registerAuthCallback(onAuth: OnAuth)
remove
Link copied to clipboard
fun remove(onComplete: OnComplete? = null)
removeAccount
Link copied to clipboard
fun removeAccount(callback: OnComplete? = null)

Removes the Webcom account of the currently authenticated user. Note that all identities attached to this account will also be deleted.

removeIdentity
Link copied to clipboard
fun removeIdentity(callback: OnComplete? = null)

Removes the identity of the currently authenticated user from her/his Webcom account. This identity will then be no longer available for authenticating the user. All other identities attached to this account will remain and will still be available for authentication. However, note that if the removed identity is the last attached one to the user account, then the whole account is deleted (otherwise it would result in a "ghost" account with no means of authentication).

removeUser
Link copied to clipboard
fun removeUser(email: String, password: String, callback: OnAuth?)
resume
Link copied to clipboard
fun resume()
root
Link copied to clipboard
fun root(): Webcom

Returns a reference on the root data node of the Datasync service associated with this instance.

sendConfirmationEmail
Link copied to clipboard
fun sendConfirmationEmail(email: String, callback: OnComplete?)
sendOtp
Link copied to clipboard
fun sendOtp(provider: String, id: String, callback: OnValue)

Sends a one time password to a user using the default "login" message template.

fun sendOtp(provider: String, id: String, messageDetails: MessageDetails?, callback: OnValue)

Sends a one time password to a user. Such a temporary password may then be used to authenticate the user using the Webcom.authInternally method.

sendPasswordResetCode
Link copied to clipboard
fun sendPasswordResetCode(provider: String, id: String, callback: OnComplete?)
fun sendPasswordResetCode(provider: String, id: String, messageDetails: MessageDetails? = null, callback: OnComplete? = null)
sendPasswordResetEmail
Link copied to clipboard
fun sendPasswordResetEmail(email: String, callback: OnAuth?)
sendVerificationCode
Link copied to clipboard
fun sendVerificationCode(provider: String, id: String, callback: OnValue?)
fun sendVerificationCode(provider: String, id: String, messageDetails: MessageDetails? = null, callback: OnValue?)
set
Link copied to clipboard
fun set(data: Any?, onComplete: OnComplete? = null)
shouldBeOnline
Link copied to clipboard
fun shouldBeOnline(): Boolean

Returns the working status of the Datasync service associated with this instance wrt. to the network connection.

startAt
Link copied to clipboard
fun startAt(name: String? = null): Query
subscribe
Link copied to clipboard
fun subscribe(jsDescriptor: Any, jsTarget: Any, callback: OnValue)
subscribeWithHuaweiNotifications
Link copied to clipboard
fun subscribeWithHuaweiNotifications(deviceId: String, event: NotificationEvent, receiveRevocations: Boolean = true, expiration: Date? = null, callback: OnComplete)

Subscribes to a given NotificationEvent on the current data node path, to be received through the HMS (Huawei Mobile Service) push mobile notifications sent to a given deviceId. This operation requires to be authenticated.

fun subscribeWithHuaweiNotifications(deviceId: String, events: EnumSet<NotificationEvent>, receiveRevocations: Boolean = true, expiration: Date? = null, callback: OnComplete)

Subscribes to a given set of NotificationEvents on the current data node path, to be received through the HMS (Huawei Mobile Service) push mobile notifications sent to a given deviceId. This operation requires to be authenticated.

subscribeWithMobileNotifications
Link copied to clipboard
fun subscribeWithMobileNotifications(deviceId: String, event: NotificationEvent, receiveRevocations: Boolean = true, expiration: Date? = null, callback: OnComplete)

Subscribes to a given NotificationEvent on the current data node path, to be received through the FCM (Firebase Cloud Messaging) push mobile notifications sent to a given deviceId. This operation requires to be authenticated.

fun subscribeWithMobileNotifications(deviceId: String, events: EnumSet<NotificationEvent>, receiveRevocations: Boolean = true, expiration: Date? = null, callback: OnComplete)

Subscribes to a given set of NotificationEvents on the current data node path, to be received through the FCM (Firebase Cloud Messaging) push mobile notifications sent to a given deviceId. This operation requires to be authenticated.

toString
Link copied to clipboard
open override fun toString(): String
transaction
Link copied to clipboard
fun transaction(callbacks: TransactionCallback, applyLocally: Boolean = true)
unregisterAuthCallback
Link copied to clipboard
fun unregisterAuthCallback(onAuth: OnAuth)
unsubscribe
Link copied to clipboard
fun unsubscribe(jsTarget: Any, receivesRevocations: Boolean, callback: OnValue? = null)
unsubscribeWithHuaweiNotifications
Link copied to clipboard
fun unsubscribeWithHuaweiNotifications(deviceId: String, callback: OnComplete? = null)

Unsubscribes from NotificationEvents on the current data node path, so that no longer HMS (Huawei Mobile Service) push mobile notifications are sent to the given deviceId. This operation requires to be authenticated.

unsubscribeWithMobileNotifications
Link copied to clipboard
fun unsubscribeWithMobileNotifications(deviceId: String, callback: OnComplete? = null)

Unsubscribes from NotificationEvents on the current data node path, so that no longer FCM (Firebase Cloud Messaging) push mobile notifications are sent to the given deviceId. This operation requires to be authenticated.

update
Link copied to clipboard
fun update(data: Any?, onComplete: OnComplete? = null)
updateEmailPasswordProfile
Link copied to clipboard
fun updateEmailPasswordProfile(data: Any?, callback: OnComplete?)
fun updateEmailPasswordProfile(path: String?, data: Any?, callback: OnComplete?)
updateIdentityProfile
Link copied to clipboard
fun updateIdentityProfile(data: Any?, callback: OnComplete?)
fun updateIdentityProfile(path: String?, data: Any?, callback: OnComplete?)
useCurrentContextForNextAuthOperation
Link copied to clipboard
fun useCurrentContextForNextAuthOperation()
useNewContextForNextAuthOperation
Link copied to clipboard
fun useNewContextForNextAuthOperation()
verifyIdentity
Link copied to clipboard
fun verifyIdentity(provider: String, id: String, data: VerificationData, callback: OnAuth)

Verifies the authentication details (typically msisdn or email address) of a newly created identity using the Webcom.addIdentity method. If the verification is successful, then the user is automatically authenticated with the verified identity.

wakeupSubscribe
Link copied to clipboard
fun wakeupSubscribe(id: String, callback: OnComplete?)
fun wakeupSubscribe(id: String, mode: String, callback: OnComplete?)
wakeupUnsubscribe
Link copied to clipboard
fun wakeupUnsubscribe(id: String, callback: OnComplete?)

Properties

application
Link copied to clipboard
val application: String
name
Link copied to clipboard
val name: String?
path
Link copied to clipboard
val path: String