# 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="https://2425324002-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fhi3J82Irfk38cjMHFvTF%2Fuploads%2FlhwkZyv4yxbXtpiHiR8R%2FScreenshot%202024-05-09%20at%202.05.03%E2%80%AFPM.png?alt=media&#x26;token=840846e7-80a8-4a03-9aad-e55e9b9db68f" 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](https://pubscale.gitbook.io/offerwall-sdk/1.0.7/prerequisites/pubscale-onboarding).
{% 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="https://2425324002-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fhi3J82Irfk38cjMHFvTF%2Fuploads%2FF3IN4OMNQRPGZ3Xisjqa%2FGroup%2078600.png?alt=media&#x26;token=677fa7df-43db-41d5-865b-9f4a0d0ae238" 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="https://2425324002-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fhi3J82Irfk38cjMHFvTF%2Fuploads%2FBkgMzr5FYDEE8GeLgeha%2FScreenshot%202024-05-09%20at%202.09.42%E2%80%AFPM.png?alt=media&#x26;token=a37716ed-c61d-4c22-8352-1312fac39a1e" 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](https://pubscale.gitbook.io/offerwall-sdk/1.0.7/sandbox-environment/sandbox-environment).
{% 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.
