# Install

Add the Screeb SDK to your app and start it with your channel id, so surveys, messages and session replay can run.

Install the Screeb SDK once, at the start of your app, with the channel id of your workspace. Until a user is identified, Screeb tracks them as an anonymous visitor: see [Identity](https://developers.screeb.app/sdk-maui/identity) to attach your own user id.

Your channel id is on the [Install page of your workspace settings](https://admin.screeb.app/org/last/settings/install). The steps on the admin side are in the help center: [Install Screeb on your website](https://help.screeb.app/install/install-web/) and [Install Screeb in your mobile app](https://help.screeb.app/install/install-mobile/).

> [!TIP]
> Turn the SDK off in your CI and end-to-end test runs. Every run creates new anonymous users, which count toward your monthly tracked users.

## Requirements

- iOS 12.0 or later and Swift 5.0 or later for the iOS SDK. Android API 19 or later for the Android SDK.
- Flutter 3.19 or later. Kotlin Multiplatform: Kotlin 2.1.0 or later, Android minSdk 21, iOS 14. .NET MAUI: Android API 24 and iOS 14.
- The SDK adds about 450 KB to an iOS release app and about 110 KB to an Android one. The iOS SDK has no third-party dependency.

## Add the SDK to your project

```sh
dotnet add package Screeb.Maui
```

## Start the SDK

```cs
using static Screeb.Maui.Screeb;

// At app start, for example in App.OnStart
await InitSdk(channelId: "<YOUR-CHANNEL-ID>");
```

Start the SDK once, when the app launches. When the user is already logged in at that point, pass their user id and properties too, so Screeb never creates an anonymous visitor for them (see [Identity](https://developers.screeb.app/sdk-maui/identity)).

## Declare permissions

The SDK needs network access. Audio and video answers, and photos taken from a survey, also need the camera and the microphone.

```xml
<!-- AndroidManifest.xml -->
<uses-permission android:name="android.permission.INTERNET" />

<!-- Only for audio and video answers -->
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-feature android:name="android.hardware.camera" android:required="false" />
```

```xml
<!-- Info.plist, only for audio and video answers -->
<key>NSCameraUsageDescription</key>
<string>This app needs access to the camera to record video answers.</string>
<key>NSMicrophoneUsageDescription</key>
<string>This app needs access to the microphone to record audio answers.</string>
```

On iOS, a video answer asks for both the camera and the microphone, and refusing either one makes it fail. Without these two keys, iOS turns audio and video answers off: respondents never see those buttons. Once a respondent refuses, iOS never asks again, so Screeb hides the buttons. Picking an existing image from the photo library needs no permission.

## Open the app from the message editor

The Screeb in-app message editor opens your app through a deep link on the `screeb-<YOUR-CHANNEL-ID>` scheme. Declare the scheme, then forward the links to the SDK.

```xml
<!-- Info.plist -->
<key>CFBundleURLTypes</key>
<array>
  <dict>
    <key>CFBundleTypeRole</key>
    <string>Viewer</string>
    <key>CFBundleURLName</key>
    <string>screeb</string>
    <key>CFBundleURLSchemes</key>
    <array>
      <string>screeb-<YOUR-CHANNEL-ID></string>
    </array>
  </dict>
</array>
```

```csharp
using static Screeb.Maui.Screeb;

// Platforms/iOS/AppDelegate.cs
public override bool OpenUrl(UIApplication app, NSUrl url, NSDictionary options)
{
    _ = HandleDeepLink(url.AbsoluteString ?? "");
    return true;
}

// Platforms/Android/MainActivity.cs, with this attribute on the activity:
// [IntentFilter(new[] { Intent.ActionView },
//     Categories = new[] { Intent.CategoryDefault, Intent.CategoryBrowsable },
//     DataScheme = "screeb-<YOUR-CHANNEL-ID>")]
protected override void OnCreate(Bundle? savedInstanceState)
{
    base.OnCreate(savedInstanceState);
    _ = HandleDeepLink(Intent?.DataString ?? "");
}

protected override void OnNewIntent(Intent? intent)
{
    base.OnNewIntent(intent);
    _ = HandleDeepLink(intent?.DataString ?? "");
}
```

## Stop the SDK

Stop Screeb at any time, for example when the user withdraws consent. It stays off until you start it again.

```csharp
await CloseSdk();
```

## Next steps

- [Identify your users](https://developers.screeb.app/sdk-maui/identity) to follow them across devices and target surveys on their properties.
- [Track events](https://developers.screeb.app/sdk-maui/event-tracking) to trigger surveys and messages on what users do.
- [Start a survey from your code](https://developers.screeb.app/sdk-maui/start-survey-programmatically) when the targeting rules are not enough.
