Methods
Dive deeper into the methods at your disposal in the ALO Javascript Presence SDK.
Constructor
Presence
Presence
Once initialized, the user is automatically connected to the presence service.
Parameters:
Name | Type | Required | Description |
authToken | string | yes | The ALO generated auth token to grant access to the ALO presence service. |
projectId | string | yes | The unique project ID associated with your app, provided by ALO. |
userId | string | yes | A unique ID to associate the online/offline events with. |
deviceId | string | no | An ID to differentiate multiple sessions or devices for the same userId. Multiple clients should not specify the same userId and deviceId pair. |
Methods
.hereNow()
.hereNow()
Fetch the current online/offline status for a list of users.
Parameters:
Name | Type | Required | Description |
userIds | array[string] | yes | A list of user IDs to check online/offline status of. |
.subscribe()
.subscribe()
Subscribe to online/offline events for a list of users. If called more than once it will not unsubscribe from user ids made in previous calls. It will only subscribe to the user ids not already subscribed.
Parameters:
Name | Type | Required | Description |
userIds | array[string] | yes | A list of user IDs to subscribe to online/offline events. |
.unsubscribeAll()
.unsubscribeAll()
Unsubscribe from all online/offline events.
.watch()
.watch()
Register a callback function to recieve online/offline events subscribed to with .subscribe()
.
Parameters:
Name | Type | Required | Description |
callback | function | yes | A callback function that is called when a subscribed user ID presence event occurs. |
.unwatchAll()
.unwatchAll()
Unregister all callbacks registered with .watch()
.
.disconnect()
.disconnect()
Disconnects the user from the presence service and unsubscribes and unwatches all events.
Last updated