Documentation

SDK Functions

Here's a list of all the functions supported by the UserView Android SDK.

Connection Management

FunctionDescription
connect()Establishes a WebSocket connection to the servers.
disconnect()Closes the connection temporarily without ending the session.
reset()Resets the connection state and reconnects if previously connected.
cleanup(keepSessionAlive: Boolean)Cleans up resources. Set keepSessionAlive to true to allow reconnection.

Session Control

FunctionDescription
stopSession()Ends the current screen sharing session.
declineSession()Declines an incoming session request.
customMessage(message: String)Sends a custom text or JSON message to the agent.

Visitor Information

FunctionReturnsDescription
getShortId()String?Returns the visitor's unique short ID.
getLookupCode()String?Returns or generates a 4-digit lookup code (expires after 1 hour).
getWatchLink()String?Returns the full URL where agents can view the session.

Updating Connection Properties

Use updateConnection() to update visitor identification after initialization:

UpscopeManager.shared?.updateConnection(
    agentPrompt = "VIP Customer",
    integrationIds = listOf("zendesk:12345"),
    identities = listOf("John Smith", "john@example.com"),
    uniqueId = "user-123",
    metadata = mapOf("plan" to "enterprise", "region" to "US")
)

Clearing Values

To clear a value, pass null. To keep existing values unchanged, omit the parameter.

// Clear the agent prompt, keep everything else
UpscopeManager.shared?.updateConnection(agentPrompt = null)

State Subscriptions

Subscribe to real-time state changes:

// Connection status
UpscopeManager.shared?.subscribeToIsConnected { isConnected ->
    println("Connected: $isConnected")
}

// Connecting status
UpscopeManager.shared?.subscribeToIsConnecting { isConnecting ->
    println("Connecting: $isConnecting")
}

// Screen capture active
UpscopeManager.shared?.subscribeToIsRecording { isRecording ->
    println("Recording: $isRecording")
}

// Short ID changes
UpscopeManager.shared?.subscribeToShortId { shortId ->
    println("Short ID: $shortId")
}

// Lookup code changes
UpscopeManager.shared?.subscribeToLookupCode { code ->
    println("Lookup code: $code")
}

// Connection ID changes
UpscopeManager.shared?.subscribeToUniqueConnectionId { connectionId ->
    println("Connection ID: $connectionId")
}

Activity Management

FunctionDescription
setupWithActivity(activity: FragmentActivity)Binds the SDK to an activity for screen capture.
bindToActivity(activity: Activity)Explicitly binds to a specific activity.
bindToActivityContaining(view: View)Binds to the activity containing the specified view.
getCurrentInstanceActivity()Returns the currently bound activity.
refreshInstanceActivityBinding()Forces a refresh of the activity binding.

Redaction Control

Property/FunctionDescription
redactionEnabledBoolean to enable/disable redaction globally. Default: true.
registerRedactionMiddleware(middleware)Registers custom coordinate-based redaction.
registerFlutterRedactionCallback(callback)Registers an async callback for Flutter redaction.
registerFrameCaptureMiddleware(middleware)Controls when frames are captured.

Logging

PropertyDescription
enableLoggingSet to true to enable SDK logs. Default: false.
showDebugLogsSet to true for detailed debug logging.

Configuration

FunctionDescription
refreshConfiguration()Forces a fetch of configuration from the server.