# Reference

Every public method of Screeb.Maui, with its signature.

Complete reference for the Screeb .NET MAUI SDK. New to Screeb? Start with the [install guide](https://developers.screeb.app/sdk-maui/install).

## Methods by capability

### Lifecycle

| Method                                                                                                                                                                                                    | Description                                                        | More                                                    |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------ | ------------------------------------------------------- |
| `InitSdk(string channelId, string? userId = null, Dictionary<string, object>? properties = null, ScreebHooks? hooks = null, ScreebInitOptions? initOptions = null, string? language = null): Task<bool?>` | Initialize the Screeb SDK. Must be called before any other method. | [Guide](https://developers.screeb.app/sdk-maui/install) |
| `CloseSdk(): Task<bool?>`                                                                                                                                                                                 | Stop the SDK. Opposite of InitSdk.                                 | [Guide](https://developers.screeb.app/sdk-maui/install) |

### Identity

| Method                                                                                   | Description                                                                                                                                                                                                               | More                                                                              |
| ---------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- |
| `SetIdentity(string userId, Dictionary<string, object>? properties = null): Task<bool?>` | Identify the current user with optional properties.                                                                                                                                                                       | [Guide](https://developers.screeb.app/sdk-maui/identity)                          |
| `SetProperties(Dictionary<string, object>? properties = null): Task<bool?>`              | Send visitor properties without changing the identity.                                                                                                                                                                    | [Guide](https://developers.screeb.app/sdk-maui/identity)                          |
| `ResetIdentity(): Task<bool?>`                                                           | Reset user identity (e.g. on logout).                                                                                                                                                                                     | [Guide](https://developers.screeb.app/sdk-maui/identity)                          |
| `SetAnonymousId(string anonymousId): Task<bool?>`                                        | Adopts the anonymous id your CDP already uses (Amplitude device id, Segment or RudderStack anonymous id) on the current respondent, which stays anonymous. Call it right after InitSdk: the call is resolved during init. | [Guide](https://developers.screeb.app/sdk-maui/identity#2-share-one-anonymous-id) |
| `GetIdentity(): Task<Dictionary<string, object>?>`                                       | Get current visitor identity and properties.                                                                                                                                                                              | [Guide](https://developers.screeb.app/sdk-maui/identity)                          |

### Groups

| Method                                                                                                           | Description                           | More                                                              |
| ---------------------------------------------------------------------------------------------------------------- | ------------------------------------- | ----------------------------------------------------------------- |
| `AssignGroup(string? groupType, string groupName, Dictionary<string, object>? properties = null): Task<bool?>`   | Assign the current user to a group.   | [Guide](https://developers.screeb.app/sdk-maui/group-assignation) |
| `UnassignGroup(string? groupType, string groupName, Dictionary<string, object>? properties = null): Task<bool?>` | Remove the current user from a group. | [Guide](https://developers.screeb.app/sdk-maui/group-assignation) |

### Tracking

| Method                                                                                 | Description                      | More                                                            |
| -------------------------------------------------------------------------------------- | -------------------------------- | --------------------------------------------------------------- |
| `TrackEvent(string name, Dictionary<string, object>? properties = null): Task<bool?>`  | Track a custom event.            | [Guide](https://developers.screeb.app/sdk-maui/event-tracking)  |
| `TrackScreen(string name, Dictionary<string, object>? properties = null): Task<bool?>` | Track a screen navigation event. | [Guide](https://developers.screeb.app/sdk-maui/screen-tracking) |

### Surveys

| Method                                                                                                                                                                                                                                              | Description                               | More                                                                          |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------- | ----------------------------------------------------------------------------- |
| `StartSurvey(string surveyId, bool allowMultipleResponses = true, Dictionary<string, object>? hiddenFields = null, bool ignoreSurveyStatus = true, ScreebHooks? hooks = null, string? language = null, string? distributionId = null): Task<bool?>` | Start a specific survey programmatically. | [Guide](https://developers.screeb.app/sdk-maui/start-survey-programmatically) |
| `CloseSurvey(string? surveyId = null): Task<bool?>`                                                                                                                                                                                                 | Close the currently displayed survey.     | -                                                                             |

### Messages

| Method                                                                                                                                                                                                                                                 | Description                                | More                                                                           |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------ | ------------------------------------------------------------------------------ |
| `StartMessage(string messageId, bool allowMultipleResponses = true, Dictionary<string, object>? hiddenFields = null, bool ignoreMessageStatus = true, ScreebHooks? hooks = null, string? language = null, string? distributionId = null): Task<bool?>` | Start a specific message programmatically. | [Guide](https://developers.screeb.app/sdk-maui/start-message-programmatically) |
| `CloseMessage(string? messageId = null): Task<bool?>`                                                                                                                                                                                                  | Close the currently displayed message.     | [Guide](https://developers.screeb.app/sdk-maui/start-message-programmatically) |

### Session replay

| Method                              | Description                     | More                                                           |
| ----------------------------------- | ------------------------------- | -------------------------------------------------------------- |
| `SessionReplayStart(): Task<bool?>` | Start session replay recording. | [Guide](https://developers.screeb.app/sdk-maui/session-replay) |
| `SessionReplayStop(): Task<bool?>`  | Stop session replay recording.  | [Guide](https://developers.screeb.app/sdk-maui/session-replay) |

### Debug

| Method                            | Description                                                   | More                                                            |
| --------------------------------- | ------------------------------------------------------------- | --------------------------------------------------------------- |
| `Debug(): Task<string?>`          | Get SDK debug information.                                    | [Guide](https://developers.screeb.app/sdk-maui/troubleshooting) |
| `DebugTargeting(): Task<string?>` | Get targeting debug information (why surveys aren't showing). | [Guide](https://developers.screeb.app/sdk-maui/troubleshooting) |

### Privacy helpers

| Method                                   | Description                                              | More                                                            |
| ---------------------------------------- | -------------------------------------------------------- | --------------------------------------------------------------- |
| `ScreebMaskText(this T element): T`      | Mask a view or component in session replay.              | [Guide](https://developers.screeb.app/sdk-maui/privacy-helpers) |
| `ScreebNoCapture(this T element): T`     | Exclude a view or component from session replay capture. | [Guide](https://developers.screeb.app/sdk-maui/privacy-helpers) |
| `ScreebId(this T element, string id): T` | Set a stable Screeb element ID for IAM targeting.        | [Guide](https://developers.screeb.app/sdk-maui/privacy-helpers) |

### Other

| Method                                    | Description                                                                                                                                                                                             | More |
| ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---- |
| `HandleDeepLink(string url): Task<bool?>` | Forward a Screeb deep link (screeb-\<channel-id> scheme) to the SDK - editor, survey and message links open in-app. Call from your platform's open-URL entry point (iOS OpenUrl / Android OnNewIntent). | -    |

## API signatures

### Lifecycle

```csharp
InitSdk(string channelId, string? userId = null, Dictionary<string, object>? properties = null, ScreebHooks? hooks = null, ScreebInitOptions? initOptions = null, string? language = null): Task<bool?>
CloseSdk(): Task<bool?>
```

### Identity

```csharp
SetIdentity(string userId, Dictionary<string, object>? properties = null): Task<bool?>
SetProperties(Dictionary<string, object>? properties = null): Task<bool?>
ResetIdentity(): Task<bool?>
SetAnonymousId(string anonymousId): Task<bool?>
GetIdentity(): Task<Dictionary<string, object>?>
```

### Groups

```csharp
AssignGroup(string? groupType, string groupName, Dictionary<string, object>? properties = null): Task<bool?>
UnassignGroup(string? groupType, string groupName, Dictionary<string, object>? properties = null): Task<bool?>
```

### Tracking

```csharp
TrackEvent(string name, Dictionary<string, object>? properties = null): Task<bool?>
TrackScreen(string name, Dictionary<string, object>? properties = null): Task<bool?>
```

### Surveys

```csharp
StartSurvey(string surveyId, bool allowMultipleResponses = true, Dictionary<string, object>? hiddenFields = null, bool ignoreSurveyStatus = true, ScreebHooks? hooks = null, string? language = null, string? distributionId = null): Task<bool?>
CloseSurvey(string? surveyId = null): Task<bool?>
```

### Messages

```csharp
StartMessage(string messageId, bool allowMultipleResponses = true, Dictionary<string, object>? hiddenFields = null, bool ignoreMessageStatus = true, ScreebHooks? hooks = null, string? language = null, string? distributionId = null): Task<bool?>
CloseMessage(string? messageId = null): Task<bool?>
```

### Session replay

```csharp
SessionReplayStart(): Task<bool?>
SessionReplayStop(): Task<bool?>
```

### Debug

```csharp
Debug(): Task<string?>
DebugTargeting(): Task<string?>
```

### Privacy helpers

```csharp
ScreebMaskText(this T element): T
ScreebNoCapture(this T element): T
ScreebId(this T element, string id): T
```

### Other

```csharp
HandleDeepLink(string url): Task<bool?>
```

## Hooks

Hooks can be passed to initialization and programmatic survey/message starts. Callback payloads are forwarded as JSON strings by the mobile wrappers.

```csharp
var hooks = new ScreebHooks
{
    Version = "1.0.0",
    Callbacks =
    {
        ["onSurveyShowed"] = async payload =>
        {
            // handle hook payload
            return null;
        },
    },
};
```

For complete hook payload definitions, see the [JS tag hooks reference](https://developers.screeb.app/sdk-maui/hooks).

## Privacy helpers

```csharp
entry.ScreebMaskText();

view.ScreebNoCapture();

button.ScreebId("checkout-button");
```

## Type definitions

```csharp
public class ScreebHooks
{
    /// <summary>Hooks version identifier passed verbatim to the native SDK.</summary>
    public required string Version { get; set; }

    /// <summary>
    /// Hook callbacks: key = hook name (e.g. "onSurveyShowed"),
    /// value = async callback receiving the JSON payload string.
    /// </summary>
    public Dictionary<string, Func<string, Task<object?>>> Callbacks { get; set; } = new();
}

public class ScreebInitOptions
{
    public bool IsDebugMode { get; set; } = false;
    public bool DisableMirror { get; set; } = false;
}
```
