# Integrate the Entitlements SDK

## Prerequisites

1. [Complete the Getting Started Guide](/guides/getting-started.md)
2. [Integrate the User SDK](/guides/users/integrate-the-user-sdk.md)

## Get Started

* [Integrate the iOS SDK](#integrate-the-ios-sdk)
* [Integrate the Android SDK](#integrate-the-android-sdk)
* [Integrate the JavaScript SDK](#integrate-the-javascript-sdk)

## Integrate the iOS SDK

To use Entitlements SDK in an iOS app, you need to install the SudoEntitlements package via Swift Package Manager

Open your project settings in XCode, and go to the `Package Dependencies` tab. Click on the `+` sign to add a dependency.&#x20;

Enter the repository URL [`https://github.com/sudoplatform/sudo-entitlements-ios`](https://github.com/sudoplatform/sudo-entitlements-ios) in the top right search box and select the `sudo-entitlements-ios` repository.&#x20;

Select the required version and `Add Package`.&#x20;

Sudo Platform SDKs conform to semantic versioning so in most cases you will leave the Dependency Rule as `Up to Next Major Version` to receive regular updates without introducing any breaking changes.

This will resolve the local package dependency and install the latest version of the Entitlements SDK.

{% hint style="info" %}
In order to instantiate a Entitlements client, make sure you have followed instructions for [Getting Started](/guides/getting-started.md) and [User SDK](/guides/users/integrate-the-user-sdk.md) (see [Prerequisites](#prerequisites) above)
{% endhint %}

### Client Initialization

To instantiate a client in your application, add the following

{% tabs %}
{% tab title="Swift" %}

```swift
import SudoEntitlements

let userClient = // ... see "Users" docs

do {
    let entitlementsClient = DefaultSudoEntitlementsClient(
        userClient: userClient
    )
} catch {
    // Handle initialization error. An error might be thrown due to invalid
    // or missing configuration file.
}
```

{% endtab %}
{% endtabs %}

{% hint style="warning" %}
You only need one client instance for a given user per device. Instantiating multiple clients with the same configuration and using them at the same time may cause unexpected runtime errors to occur.
{% endhint %}

{% hint style="success" %}
**See it in action**. Be sure to take a look at the [open source iOS sample app](https://github.com/sudoplatform/samples-ios) on Github that our team published as a reference for integrating the Entitlements SDK into your app as quickly and seamlessly as possible.
{% endhint %}

## Integrate the Android SDK

{% tabs %}
{% tab title="Gradle" %}
Add this line to the dependencies section of the app module `build.gradle` and synchronize your project with Android Studio.

```
dependencies {
    implementation 'com.sudoplatform:sudoentitlements:$latest'
}
```

{% hint style="info" %}
In order to instantiate a Entitlements client, make sure you have followed instructions for [Getting Started](https://github.com/sudoplatform/developer-documentation/tree/7df19c270e90d50d373eb3b71cecb2cd68b5b32a/guides/entitlements/getting-started.md) and [User SDK](https://github.com/sudoplatform/developer-documentation/tree/7df19c270e90d50d373eb3b71cecb2cd68b5b32a/guides/entitlements/users/integrate-the-user-sdk.md) (see Prerequisites above)
{% endhint %}
{% endtab %}
{% endtabs %}

### Client Initialization

To instantiate a client in your application, add the following

{% tabs %}
{% tab title="Kotlin" %}

```kotlin
val userClient = // ... see "Users" docs

val entitlementsClient = SudoEntitlementsClient.builder()
    .setContext(appContext)
    .setSudoUserClient(userClient)
    .build()
```

{% endtab %}
{% endtabs %}

{% hint style="warning" %}
You only need one client instance for a given user per device. Instantiating multiple clients with the same configuration and using them at the same time may cause unexpected runtime errors to occur.
{% endhint %}

{% hint style="success" %}
**See it in action.** Be sure to take a look at the [open source Android sample app](https://github.com/sudoplatform/samples-android) on Github that our team published as a reference for integrating the Entitlements SDK into your app as quickly and seamlessly as possible.
{% endhint %}

## Integrate the JavaScript SDK

The JavaScript SDK is open source and compatible with CommonJS module loading.

{% tabs %}
{% tab title="NPM" %}
Add this line to the `dependencies` section of your application's `package.json` file.

```
dependencies {
  '@sudoplatform/sudo-entitlements':'$latest'
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
In order to instantiate a Entitlements client, make sure you have followed instructions for [Getting Started](https://github.com/sudoplatform/developer-documentation/tree/7df19c270e90d50d373eb3b71cecb2cd68b5b32a/guides/entitlements/getting-started.md) and [User SDK](https://github.com/sudoplatform/developer-documentation/tree/7df19c270e90d50d373eb3b71cecb2cd68b5b32a/guides/entitlements/users/integrate-the-user-sdk.md) (see Prerequisites above)
{% endhint %}

### Client Initialization

To instantiate a client in your application, add the following

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const DefaultSudoEntitlementsClient
  = require('@sudoplatform/sudo-entitlements')
    .DefaultSudoEntitlementsClient
const userClient = // see "Users" docs

const entitlementsClient =
  new DefaultSudoEntitlementsClient(userClient)
```

{% endtab %}
{% endtabs %}

{% hint style="warning" %}
You only need one client instance for a given user per device. Instantiating multiple clients with the same configuration and using them at the same time may cause unexpected runtime errors to occur.
{% endhint %}

{% hint style="success" %}
**See it in action.** Be sure to take a look at the [open source JavaScript sample app](https://github.com/sudoplatform/samples-javascript) on Github that our team published as a reference for integrating the Entitlements SDK into your web application as quickly and seamlessly as possible.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sudoplatform.com/guides/entitlements/end-user-api/integrate-the-entitlements-sdk.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
