# Install SDK

## 1. Introduction

This guide provides a comprehensive walkthrough for integrating the MyChips SDK into your Flutter application, enabling the display of an engaging offerwall.

## 2. SDK Integration

To add the package to your project folder using the terminal:

```shell
 $ flutter pub add my_chips_flutter_sdk
```

Now in your main.dart code, you can import it:

```dart
import 'package:my_chips_flutter_sdk/my_chips_flutter_sdk.dar
```

## 3. Initializating the SDK

Before using the sdk or showing the offerwall you must initialize it:

```dart
//replace "YOUR_API_KEY"
await MCOfferwallSdk.instance.init("YOUR_API_KEY");
```

> Obtain your API key and User ID from [Universal Developer Portal](https://dashboard.maf.ad)

#### **3.1 (Mandatory)** – Set **Google Advertising ID (Android)** and **Identifier for Advertisers (iOS)**

Improve reward tracking and eCPM performance by passing the Google Advertising ID ([Official documentation](https://developer.android.com/training/articles/ad-id)) for Android devices and the IDFA for iOS devices.

**Android:**

```dart
await MCOfferwallSdk.instance.setGaid("YOUR_GAID");
```

Replace "YOUR\_GAID" with your actual Google Advertising ID variable or value.

**iOS:**

```dart
await MCOfferwallSdk.instance.setIdfa("YOUR_IDFA");
```

Replace "YOUR-IDFA" with your actual IDFA variable or value.

#### 3.2 (Optional) Set userId if you have your own unique id

```dart
//replace "YOUR_USER_ID"
await MCOfferwallSdk.instance.setUserId("YOUR_USER_ID"); 
```

&#x20;   Replace `"`YOUR\_USER\_ID`"` with your actual user ID variable or value.

&#x20;   If you do not provide a specific user ID, one will be automatically generated.

#### 3.3 (Optional) Set User Age

You can set the user’s age to help improve ad targeting and analytics.

```dart
 await MCOfferwallSdk.instance.setAge(30);
```

Replace 30 with your actual user age variable or value (integer).

💡 **Note:**

* The value should be an integer (e.g., 18, 25, 30).
* Expected range is 0–100 (inclusive).

#### 3.4 (Optional) Set User Gender

You can set the user’s gender to help improve ad targeting and analytics.

```dart
  await MCOfferwallSdk.instance.setGender(MCGenderEnum.male);
```

Available enum values:

```dart
  MCGenderEnum.male
  MCGenderEnum.female
  MCGenderEnum.other
```

#### 3.5 (Optional) Set Custom Parameters (`aff_sub1`–`aff_sub5` )

We provide 5 `aff_sub` parameters (`aff_sub1`, `aff_sub2`, `aff_sub3`, `aff_sub4`, `aff_sub5`), which you can use to pass custom values.

```dart
MCOfferwallSDK.setAffSub1("HERE YOUR CUSTOM VALUE");
MCOfferwallSDK.setAffSub2("HERE YOUR CUSTOM VALUE");
MCOfferwallSDK.setAffSub3("HERE YOUR CUSTOM VALUE");
MCOfferwallSDK.setAffSub4("HERE YOUR CUSTOM VALUE");
MCOfferwallSDK.setAffSub5("HERE YOUR CUSTOM VALUE");
```

Replace `"`HERE YOUR CUSTOM VALUE`"` with your actual custom value.

## **4. Display the Offerwall**

To show the offerwall we provide you with a widget called OfferwallPage. You should show it as a page using your preferred navigation package/method.

Example using the default flutter navigator:

```dart
//replace "YOUR_AD_UNIT_ID"
Navigator.of(context).push(
    MaterialPageRoute(
        builder: (context) => OfferwallPage(
        adunitId: "YOUR_AD_UNIT_ID",
        ),
    ),
);
```

> Your Ad unit ID can be found at [here](http://dashboard.maf.ad)

#### Optional: Enable the Top Bar with Close Button

The Offerwall supports an optional top bar with a close button.\
This feature is **disabled by default** to avoid interfering with the host app’s UI.

To enable the top bar, set `showTopBar: true` when opening the Offerwall:

```dart
Navigator.of(context).push(
  MaterialPageRoute(
    builder: (context) => OfferwallPage(
      adunitId: "YOUR_AD_UNIT_ID",
      showTopBar: true, // Enables top bar with close button
    ),
  ),
);
```


---

# 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.mychips.io/flutter/install-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.
