SDK Functions
Here's a list of all the functions and properties supported by the UserView Android SDK.
All methods and properties are accessed through the Upscope singleton object.
Connection Management
| Function | Description |
|---|---|
connect() | Establishes a WebSocket connection to the servers. |
disconnect() | Closes the connection and ends any active session. |
reset(reconnect: Boolean = true) | Resets the connection, clearing all stored identities and visitor data. Pass false to stay disconnected after reset. |
Session Control
| Function | Description |
|---|---|
stopSession() | Ends the current screen sharing session. |
requestAgent() | Signals that the visitor wants assistance from an agent. |
cancelAgentRequest() | Cancels a pending agent request. |
getLookupCode() | Requests a 4-digit lookup code from the server. Access the code via the lookupCode property or lookupCodeFlow. |
sendCustomMessage(message: String) | Sends a custom text or JSON message to the agent (max 5000 characters). |
State Properties
| Property | Type | Description |
|---|---|---|
isConnected | Boolean | Whether the SDK is currently connected to the server. |
isInSession | Boolean | Whether a screen sharing session is currently active. |
connectionState | ConnectionState | Current connection state (Inactive, Connecting, Connected, Reconnecting, Error). |
sessionState | SessionState | Current session state (INACTIVE, PENDING_REQUEST, ACTIVE, PAUSED, ENDED). |
shortId | String? | The visitor's unique short ID assigned by the server. |
lookupCode | String? | The current 4-digit lookup code, if one has been generated. |
watchLink | String? | The full URL where agents can view the session (https://upscope.com/w/{shortId}). |
Visitor Identification
You can set visitor identity either through direct property assignment or as a batch update.
Direct Properties
Upscope.uniqueId = "user-123"
Upscope.callName = "John Smith"
Upscope.tags = listOf("#VIP")
Upscope.identities = listOf("John Smith", "john@example.com")
Upscope.metadata = mapOf("plan" to "enterprise", "region" to "US")
Batch Update
Use updateConnection() to update multiple fields at once:
Upscope.updateConnection(
uniqueId = "user-123",
callName = "John Smith",
tags = listOf("#VIP"),
identities = listOf("John Smith", "john@example.com"),
metadata = mapOf("plan" to "enterprise", "region" to "US")
)
Pass null to keep an existing value unchanged. Only non-null parameters are updated.
Reactive State (StateFlow)
Subscribe to state changes using Kotlin StateFlow:
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.launch
// In a coroutine scope (e.g., viewModelScope, lifecycleScope)
// Connection state changes
launch {
Upscope.connectionStateFlow.collect { state ->
println("Connection: $state")
}
}
// Session state changes
launch {
Upscope.sessionStateFlow.collect { state ->
println("Session: $state")
}
}
// Short ID changes
launch {
Upscope.shortIdFlow.collect { shortId ->
println("Short ID: $shortId")
}
}
// Lookup code changes
launch {
Upscope.lookupCodeFlow.collect { code ->
println("Lookup code: $code")
}
}
Masking
Hide sensitive content from agents during screen sharing.
| Property/Function | Description |
|---|---|
maskSecureInputs | Boolean — Automatically mask secure input fields. Default: true. |
addMaskedView(view: View) | Register a view to be masked (hidden from agent). |
removeMaskedView(view: View) | Unregister a masked view. |
allMaskedViews | List — All currently masked views. |
Example
// Mask a specific view
Upscope.addMaskedView(creditCardField)
// Later, remove the mask
Upscope.removeMaskedView(creditCardField)
// Disable automatic secure input masking
Upscope.maskSecureInputs = false
