> For the complete documentation index, see [llms.txt](https://pubscale.gitbook.io/offerwall-sdk/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://pubscale.gitbook.io/offerwall-sdk/1.0.7/unity/integration.md).

# Integration

{% hint style="info" %}
OfferWall does not work in the Editor. Please use a real device to test the integration.
{% endhint %}

### 1. Configuring Prefabs <a href="#id-1.-configuring-prefabs" id="id-1.-configuring-prefabs"></a>

#### **Drag and Drop** PubScaleOfferwallObject **prefab**

Drag and drop the **PubScaleOfferwallObject prefab** from Assets/OfferWall/Prefab/PubScaleOfferwallObject.prefab in the scene.

### 2. Configuring App Key <a href="#id-2.-configuring-app-key" id="id-2.-configuring-app-key"></a>

Enter your PubScale app ID inside the "Pubscale App ID" field located on the PubScaleOfferwallObject.

<figure><img src="/files/07MA5aFoFWlkqTQrPt3q" alt=""><figcaption><p>Offerwall Prefab</p></figcaption></figure>

{% hint style="info" %}
The PubScale App ID is an 8-digit identifier generated during the app creation process within the dashboard. If you need help creating an account/app with us, [click here](/offerwall-sdk/1.0.7/prerequisites/pubscale-onboarding.md).
{% endhint %}

### 3. Initialize the SDK <a href="#id-2.-configuring-app-key" id="id-2.-configuring-app-key"></a>

To launch the OfferWall, call the PubScaleOfferwallClient.Initialize(string userId) function using the instance from PubScaleOfferwallObject prefab.&#x20;

<pre><code><strong>PubScaleOfferwallClient myScriptInstance = GetComponent&#x3C;PubScaleOfferwallClient>();
</strong>// Check if the script instance is not null
if (myScriptInstance != null)
{
    myScriptInstance.InitOfferWall(userId);
}
</code></pre>

{% hint style="info" %}
Expected params:

1. userID:  A string value that is used to identify the user uniquely in your application. If this value is null, the SDK would internally create a userId for the device.&#x20;
   {% endhint %}

### 4. Custom loader background image and foreground image <a href="#id-2.-configuring-app-key" id="id-2.-configuring-app-key"></a>

<figure><img src="/files/jWr37i4eC69kqdqvAtPb" alt=""><figcaption></figcaption></figure>

#### **Step 1: Custom loader background and loader foreground**

To use custom background and foreground images for the loading screen replace the **demo\_background\_img and demo\_foreground\_img** file located under Assets/OfferWall/Resources with the image you need.

#### **Step 2: Enable Read and Write under Advance Image settings**

Press the preset button on your imported image and then select the OfferWallTextureImporter preset from the menu and click apply.

{% hint style="info" %}
If the fields are left empty, the default values will be used:

* Background: Black image
* Foreground: App icon
  {% endhint %}

### 5. Set Offerwall Orientation <a href="#id-2.-configuring-app-key" id="id-2.-configuring-app-key"></a>

By default, the Offerwall opens in Portrait orientation. If you want to change this behaviour, do the following changes.

Add the below line inside the \<application>\</application> tag in your AndroidManifest.xml file.

```xml
<activity android:name="com.pubscale.sdkone.offerwall.ui.OfferWallActivity" android:screenOrientation="landscape" />
```

### 6. Handling the SDK callbacks (optional) <a href="#id-2.-configuring-app-key" id="id-2.-configuring-app-key"></a>

To handle the SDK callbacks, subscribe to the events that are made available by the SimpleIntegration script.

```csharp
//Define functions that would be called when the callbacks are given
void OnSDKInitSuccess() {
    
}

void OnSDKInitFailed(string message) {
    
}

void OnOfferwallShowed() {
    
}

void OnOfferwallClosed() {
    
}

void OnRewardClaimed(Reward reward) {
    
}

void OnOfferwallFailed(string message) {
    
}

//Subscribe to the events
PubScaleOfferwallClient.OnSDKInitSuccess += OnSDKInitSuccess;
PubScaleOfferwallClient.OnSDKInitFailed += OnSDKInitFailed;
PubScaleOfferwallClient.OnOfferwallShowed += OnOfferwallShowed;
PubScaleOfferwallClient.OnOfferwallClosed += OnOfferwallClosed;
PubScaleOfferwallClient.OnRewardClaimed += OnRewardClaimed;
PubScaleOfferwallClient.OnOfferwallFailed += OnOfferwallFailed;
```

### 7. Launch the OfferWall <a href="#id-2.-configuring-app-key" id="id-2.-configuring-app-key"></a>

To launch the OfferWall, call the AdvancedIntegration.ShowOfferWall() function using the PubScaleOfferwallAdvanced prefab.&#x20;

```
PubScaleOfferwallClient myScriptInstance = GetComponent<PubScaleOfferwallClient>();
// Check if the script instance is not null
if (myScriptInstance != null)
{
    myScriptInstance.ShowOfferWall();
}
```

Can also be used in onClick of a button:

<figure><img src="/files/LWpHm3IWfjlQatQbJ2Cl" alt=""><figcaption><p>Example usage: Launching Offerwall on click of a button</p></figcaption></figure>

### 8. Test the OfferWall <a href="#id-3.-test-the-offerwall" id="id-3.-test-the-offerwall"></a>

{% hint style="info" %}
Please use the sandbox environment for testing purposes to get instant callbacks and rewards. To learn how to enable the Sandbox environment, [click here](/offerwall-sdk/1.0.7/sandbox-environment/sandbox-environment.md).
{% endhint %}

Finally, To test the offer wall, build the application to an actual device. Check if you can launch the Offerwall and get the appropriate callbacks.
