# Initialize the SDK

You must initialize the SDK before using the SDK. To do this, call `Offerwall.init(OfferWallConfig, OfferWallInitListener)` .

Parameters for init call:

* **OfferWallConfig offerWallConfig:** An object to pass configuration-related info to the SDK while initializing. Refer below for how to create an object of OfferWallConfig.
* **OfferWallInitListener offerWallInitListener:** A listener that informs you if the SDK initialization was successful or not. In case of failure, it will also give you a string stating the cause of the failure. This parameter is optional.&#x20;

### **Creating OfferWallConfig object:**

Create an instance of OfferWallConfig using the builder class OfferWallConfig.Builder by passing the context and your PubScale app ID.

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

```kotlin
import com.pubscale.sdkone.offerwall.OfferWallConfig
..
..
val offerWallConfig = OfferWallConfig.Builder(context, "YOUR_PUBSCALE_APP_ID")
   .setUniqueId("unique_id") //optional, used to represent the user of your application
   .setLoaderBackgroundBitmap(backgroundBitmap) //optional
   .setLoaderForegroundBitmap(foreground) //optional
   .setFullscreenEnabled(false) //optional
   .build()
```

{% endtab %}

{% tab title="Java" %}

```java
import com.pubscale.sdkone.offerwall.OfferWallConfig
..
..
OfferWallConfig offerWallConfig =
       new OfferWallConfig.Builder(context, "YOUR_PUBSCALE_APP_ID")
               .setUniqueId("unique_id") //optional, used to represent the user of your application
               .setLoaderBackgroundBitmap(backgroundBitmap)//optional
               .setLoaderForegroundBitmap(foregroundBitmap)//optional
               .setFullscreenEnabled(false)//optional
               .build();
```

{% endtab %}
{% endtabs %}

These are the public methods available for OfferWallConfig.Builder class:

<table><thead><tr><th width="213">Public Methods</th><th>Description</th></tr></thead><tbody><tr><td>setUniqueId(String uniqueId)</td><td>Sets a unique id that will be used to identify the user uniquely. This will be sent back in the postback.</td></tr><tr><td>setFullscreenEnabled(Boolean isEnabled)</td><td>Sets if the offerwall should open in fullscreen mode or not.<br>Default: false</td></tr><tr><td>setLoaderBackgroundBitmap(Bitmap bitmap)</td><td>Accepts a bitmap and uses it as the background image for the loader and offerwall top banner.<br>Default: Black color image</td></tr><tr><td>setLoaderForegroundBitmap(Bitmap bitmap)</td><td>Accepts a bitmap and uses it as the foreground image for the loader and offerwall top banner.<br>Default: App icon</td></tr><tr><td>build()</td><td>Builds the config and returns OfferWallConfig instance</td></tr></tbody></table>

{% hint style="danger" %}
If a unique ID is not set, rewarding the user is not guaranteed.
{% endhint %}

###

### **Initialize the Offerwall SDK:**

Initialize the OfferWall SDK by calling the init function by passing the offer wall config.

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

```kotlin
OfferWall.init(offerWallConfig, object : OfferWallInitListener {
   override fun onInitSuccess() {
   }
   override fun onInitFailed(error: InitError) {
   }
})
```

{% endtab %}

{% tab title="Java" %}

```java
OfferWall.init(offerWallConfig, new OfferWallInitListener() {
   @Override
   public void onInitSuccess() {

   }

   @Override
   public void onInitFailed(@NonNull InitError error) {

   }
});
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
OfferWallInitListener is an optional parameter in init() method.
{% endhint %}

{% hint style="info" %}
If you need to change any config after initializing the SDK, you should destroy and re-init the SDK.&#x20;

To destroy, call `OfferWall.destroy()`
{% endhint %}
