# Reference

Every public method of the Screeb Android SDK, with its signature.

Complete reference for the Screeb Android SDK: methods of the `Screeb` object. New to Screeb? Start with the [install guide](https://developers.screeb.app/sdk-android/install).

## Methods by capability

### Lifecycle

| Method                                                                                                                                                                                                                   | Description                | More                                                       |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------- | ---------------------------------------------------------- |
| `initSdk(context: Context?, channelId: String, visitorId: String? = null, visitorProperties: VisitorProperties? = null, initOptions: InitOptions = InitOptions(), hooks: GlobalHooks? = null, language: String? = null)` | Initialize the Screeb SDK. | [Guide](https://developers.screeb.app/sdk-android/install) |
| `closeSdk()`                                                                                                                                                                                                             | Stop the SDK.              | [Guide](https://developers.screeb.app/sdk-android/install) |

### Identity

| Method                                                                              | Description                                                                                                                                                                                                                                                                                                                                                                                            | More                                                                                 |
| ----------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ |
| `setIdentity(uniqueVisitorId: String, properties: TrackingEventProperties? = null)` | Identify the current user with optional properties.                                                                                                                                                                                                                                                                                                                                                    | [Guide](https://developers.screeb.app/sdk-android/identity)                          |
| `resetIdentity()`                                                                   | Reset the current visitor identity.                                                                                                                                                                                                                                                                                                                                                                    | [Guide](https://developers.screeb.app/sdk-android/identity)                          |
| `setAnonymousId(anonymousId: String)`                                               | Adopts the anonymous id your CDP already uses (Amplitude device id, Segment or RudderStack anonymous id) on the current respondent, which stays anonymous. When the CDP integration already created a respondent for that id, Screeb switches to it, unless the current respondent is identified. Call it right after \[initSdk]: the command is queued and resolved during init. 5 to 128 characters. | [Guide](https://developers.screeb.app/sdk-android/identity#2-share-one-anonymous-id) |
| `setVisitorProperties(visitorProperties: VisitorProperties)`                        | Send visitor properties without changing the identity.                                                                                                                                                                                                                                                                                                                                                 | -                                                                                    |
| `getIdentity(callback: (HashMap<String, Any?>?, Exception?) -> Unit)`               | Get the current visitor identity and properties.                                                                                                                                                                                                                                                                                                                                                       | [Guide](https://developers.screeb.app/sdk-android/identity)                          |

### Groups

| Method                                                                                   | Description                           | More                                                                 |
| ---------------------------------------------------------------------------------------- | ------------------------------------- | -------------------------------------------------------------------- |
| `assignGroup(type: String? = null, name: String, properties: GroupProperties? = null)`   | Assign the current user to a group.   | [Guide](https://developers.screeb.app/sdk-android/group-assignation) |
| `unassignGroup(type: String? = null, name: String, properties: GroupProperties? = null)` | Remove the current user from a group. | [Guide](https://developers.screeb.app/sdk-android/group-assignation) |

### Tracking

| Method                                                                                | Description                      | More                                                               |
| ------------------------------------------------------------------------------------- | -------------------------------- | ------------------------------------------------------------------ |
| `trackEvent(name: String, trackingEventProperties: TrackingEventProperties? = null)`  | Track a custom event.            | [Guide](https://developers.screeb.app/sdk-android/event-tracking)  |
| `trackScreen(name: String, trackingEventProperties: TrackingEventProperties? = null)` | Track a screen navigation event. | [Guide](https://developers.screeb.app/sdk-android/screen-tracking) |

### Surveys

| Method                                                                                                                                                                                                                                | Description                               | More                                                                             |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------- | -------------------------------------------------------------------------------- |
| `startSurvey(surveyId: String, allowMultipleResponses: Boolean = true, hiddenFields: HiddenFields? = null, ignoreSurveyStatus: Boolean = true, hooks: SurveyHooks? = null, language: String? = null, distributionId: String? = null)` | Start a specific survey programmatically. | [Guide](https://developers.screeb.app/sdk-android/start-survey-programmatically) |
| `closeSurvey(surveyId: String? = null)`                                                                                                                                                                                               | Close the currently displayed survey.     | -                                                                                |

### Messages

| Method                                                                                                                                                                                                                                   | Description                                | More                                                                              |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ | --------------------------------------------------------------------------------- |
| `startMessage(messageId: String, allowMultipleResponses: Boolean = true, hiddenFields: HiddenFields? = null, ignoreMessageStatus: Boolean = true, hooks: SurveyHooks? = null, language: String? = null, distributionId: String? = null)` | Start a specific message programmatically. | [Guide](https://developers.screeb.app/sdk-android/start-message-programmatically) |
| `closeMessage(messageId: String? = null)`                                                                                                                                                                                                | Close the currently displayed message.     | [Guide](https://developers.screeb.app/sdk-android/start-message-programmatically) |

### Session replay

| Method                 | Description                     | More                                                              |
| ---------------------- | ------------------------------- | ----------------------------------------------------------------- |
| `sessionReplayStart()` | Start session replay recording. | [Guide](https://developers.screeb.app/sdk-android/session-replay) |
| `sessionReplayStop()`  | Stop session replay recording.  | [Guide](https://developers.screeb.app/sdk-android/session-replay) |

### Debug

| Method                                                             | Description                      | More                                                               |
| ------------------------------------------------------------------ | -------------------------------- | ------------------------------------------------------------------ |
| `debug(callback: ((String, Exception?) -> Unit)? = null)`          | Get SDK debug information.       | [Guide](https://developers.screeb.app/sdk-android/troubleshooting) |
| `debugTargeting(callback: ((String, Exception?) -> Unit)? = null)` | Get targeting debug information. | [Guide](https://developers.screeb.app/sdk-android/troubleshooting) |

### Privacy helpers

| Method                      | Description                                              | More                                                               |
| --------------------------- | -------------------------------------------------------- | ------------------------------------------------------------------ |
| `View.screebMaskText()`     | Mask a view or component in session replay.              | [Guide](https://developers.screeb.app/sdk-android/privacy-helpers) |
| `View.screebNoCapture()`    | Exclude a view or component from session replay capture. | [Guide](https://developers.screeb.app/sdk-android/privacy-helpers) |
| `View.screebId(id: String)` | Set a stable Screeb element ID for IAM targeting.        | [Guide](https://developers.screeb.app/sdk-android/privacy-helpers) |

### Other

| Method                                           | Description                                                                                             | More                                                         |
| ------------------------------------------------ | ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ |
| `handleDeepLink(url: Uri?)`                      | Forward a Screeb deep link to the SDK, so editor, survey and message links open in-app.                 | -                                                            |
| `handleDeepLink(url: String?)`                   | Forward a Screeb deep link to the SDK, so editor, survey and message links open in-app.                 | -                                                            |
| `handleDeepLink(intent: Intent?)`                | Forward a Screeb deep link to the SDK, so editor, survey and message links open in-app.                 | -                                                            |
| `setColorScheme(scheme: String)`                 | Forces the survey color scheme: "light", "dark" or "auto" (follow the app appearance).                  | [Guide](https://developers.screeb.app/sdk-android/dark-mode) |
| `startSurveyFromNotification(surveyId: String?)` | **Deprecated.** Use startSurvey method. Start the survey of a Screeb push notification the user tapped. | -                                                            |

## API signatures

### Lifecycle

```kotlin
initSdk(context: Context?, channelId: String, visitorId: String? = null, visitorProperties: VisitorProperties? = null, initOptions: InitOptions = InitOptions(), hooks: GlobalHooks? = null, language: String? = null)
closeSdk()
```

### Identity

```kotlin
setIdentity(uniqueVisitorId: String, properties: TrackingEventProperties? = null)
resetIdentity()
setAnonymousId(anonymousId: String)
setVisitorProperties(visitorProperties: VisitorProperties)
getIdentity(callback: (HashMap<String, Any?>?, Exception?) -> Unit)
```

### Groups

```kotlin
assignGroup(type: String? = null, name: String, properties: GroupProperties? = null)
unassignGroup(type: String? = null, name: String, properties: GroupProperties? = null)
```

### Tracking

```kotlin
trackEvent(name: String, trackingEventProperties: TrackingEventProperties? = null)
trackScreen(name: String, trackingEventProperties: TrackingEventProperties? = null)
```

### Surveys

```kotlin
startSurvey(surveyId: String, allowMultipleResponses: Boolean = true, hiddenFields: HiddenFields? = null, ignoreSurveyStatus: Boolean = true, hooks: SurveyHooks? = null, language: String? = null, distributionId: String? = null)
closeSurvey(surveyId: String? = null)
```

### Messages

```kotlin
startMessage(messageId: String, allowMultipleResponses: Boolean = true, hiddenFields: HiddenFields? = null, ignoreMessageStatus: Boolean = true, hooks: SurveyHooks? = null, language: String? = null, distributionId: String? = null)
closeMessage(messageId: String? = null)
```

### Session replay

```kotlin
sessionReplayStart()
sessionReplayStop()
```

### Debug

```kotlin
debug(callback: ((String, Exception?) -> Unit)? = null)
debugTargeting(callback: ((String, Exception?) -> Unit)? = null)
```

### Privacy helpers

```kotlin
View.screebMaskText()
View.screebNoCapture()
View.screebId(id: String)
```

### Other

```kotlin
handleDeepLink(url: Uri?)
handleDeepLink(url: String?)
handleDeepLink(intent: Intent?)
setColorScheme(scheme: String)
startSurveyFromNotification(surveyId: String?)
```

## Type definitions

```kotlin
data class InitOptions ( var isDebugMode: Boolean = false, var disableMirror: Boolean = false, // false -> drop the overlay WebView's forced hardware layer (LAYER_TYPE_NONE), // removing a full-screen GPU buffer; A/B for the Chromium "tile memory" warning. var webViewHardwareLayer: Boolean = true, // "light" | "dark" | "auto"; null keeps the tag default. var colorScheme: String? = null, ) {
```
