# Initialization

To get started with the `@tyrads.com/tyrads-sdk` package, you will need to:

1. &#x20;Request an API key and API secret from the TyrAds team.
2. Initialize the SDK by calling `Tyrads.init()` and passing in your&#x20;
   1. API key&#x20;
   2. API secret&#x20;
   3. encKey: It stands for "encryption key" and would be used for encrypting data transmitted from the SDK. If not provided, data will be transmitted plain form.
   4. engagementId: \**Optional*\* Unique identifier for tracking user engagement.
   5. mediaSource: To maximize the value to the user sending us more data about the user and where they came from allow us to customize the reward experience. This can be used to provide feedback of quality of users as well as customize the earnings journey of different segments of users.&#x20;
   6. userInfo:  Data on user information.

```js
import Tyrads, { type TyradsMediaSourceInfo, type TyradsUserInfo } from '@tyrads.com/tyrads-sdk';

const mediaSource: TyradsMediaSourceInfo = {
  mediaSourceName: "ExampleSource",
  mediaCampaignName: "Spring Campaign",
  mediaSourceId: "src123",
  mediaSubSourceId: "subSrc456",
  incentivized: true,
  mediaAdsetName: "AdSet A",
  mediaAdsetId: "adset789",
  mediaCreativeName: "Creative X",
  mediaCreativeId: "creative101",
  sub1: "value1",
  sub2: "value2",
  sub3: "value3",
  sub4: "value4",
  sub5: "value5",
};

const userInfo: TyradsUserInfo = {
  email: "demo@example.com",
  phoneNumber: "+1234567890",
  userGroup: "premium_users",
}

await Tyrads.init(
  "apiKey",
  "apiSecret",
  "encKey",
  "engagementId",
  mediaSource,
  userInfo,
);

```

3. Login the user by calling `Tyrads.loginUser()` and passing in the user's ID.
4. Call `Tyrads.showOffers()` to display the offers.

**Launch Mode**

**Min SDK version required: v1.1.6**

**Works only for iOS**

Tyrads SDK provides the ability to open the Offerwall in a webkit view that is embedded in the app to provide a seamless user experience. Also, it provides the ability to open the Offerwall in an external browser (Safari) if Apple's app store policy does not approve the in-app rewards system for the app.

Available launch modes:

* `launchMode: 3` - opens the Offerwall in an external browser (Safari)
* `launchMode: 2` - opens the Offerwall in a webkit view that is embedded in the app

```js

// Note: The launchMode parameter is optional, if not specified the default would be opening the Offerwall in an external browser (Safari)

Tyrads.showOffers({ launchMode: 3 });// provide launchMode: 2 to open the Offerwall in a webkit view that is embedded in the app

```


---

# 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://sdk-doc.tyrads.com/v3.0/react-native/initialization.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.
