# iOS

## 1. Integration

{% hint style="warning" %}
**Before you start**&#x20;

To set up the PubScale Offerwall, you’ll need to add your app to our platform. Follow this guide for instructions on [how to set up your app](/offerwall-sdk/basic-integration/setting-up-your-app.md). Once completed, you will receive a unique 8-digit app ID.
{% endhint %}

<figure><picture><source srcset="/files/0qyOS8aIfadyjVcYovhI" media="(prefers-color-scheme: dark)"><img src="/files/LG5yJCK0VQF0iAXrFmGB" alt=""></picture><figcaption></figcaption></figure>

To integrate the PubScale Offerwall, you need to construct a URL and provide a set of  parameters for proper configuration.

**Construct the Offerwall URL**

<pre class="language-html"><code class="lang-html"><strong>https://wow.pubscale.com?app_id={app_id}&#x26;user_id={user_id}&#x26;idfa={idfa}
</strong></code></pre>

&#x20;**Parameters**

| Parameters                          | Description                                                                                                                                                            |
| ----------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **app\_id** (Required)              | This is the unique identifier for your app, required for integration.                                                                                                  |
| **user\_id** (Required)             | A unique identifier for each user, required to track their activity on the offerwall. We recommend using a UUID as the user\_id.                                       |
| **idfa** (Optional but Recommended) | For iOS integrations Include the **idfa** as a parameter when launching the  Offerwall. This helps enhance tracking accuracy and plays a key role in fraud prevention. |

To integrate the PubScale Offerwall into your iOS App, you have the following options:

### Using SFSafariViewController:&#x20;

For optimal performance and user experience, we recommend launching the Offerwall using `SFSafariViewController`&#x20;

Here's a simple Swift example that opens PubScale Offerwall in a `SFSafariViewController` on iOS

```swift
import UIKit
import SafariServices

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        openLinkInSafariViewController()
    }

    func openLinkInSafariViewController() {
        if let url = URL(string: "https://wow.pubscale.com?app_id={app_id}&user_id={user_id}&idfa={idfa}") {
            let safariVC = SFSafariViewController(url: url)
            safariVC.modalPresentationStyle = .formSheet
            present(safariVC, animated: true, completion: nil)
        } else {
            print("Invalid URL")
        }
    }
}

```

#### Notes:

* This code should be placed in a `UIViewController` subclass.
* You can call `openLinkInSafariViewController()` when appropriate (e.g., on a button tap or in `viewDidLoad` as shown).
* Don't forget to import `SafariServices`.
* Don't forget to replace the {app\_id} ,{user\_id} and {idfa} with the actula value.
* If your  App is not approved from PubScale you might see an error page.\
  \
  ![](/files/BtLEmCd6LtAui237Jz12)\
  \
  If you see this error,&#x20;

  * Check your App ID and make sure it is correct.
  * If your App ID is correct then its possible your App ID is not approved yet, in that case please reach out to your Account Manager to get your App approved.<br>

  If your configuration is correct, you will see a page similar to the screenshot below.\
  \ <img src="/files/x2KM3v2Q2W2zQKcUMwxz" alt="" data-size="original">

## 2. Setup Server-to-Server(S2S) callbacks <a href="#id-3.-test-the-offerwall" id="id-3.-test-the-offerwall"></a>

Set up the Server-to-Server (S2S) callbacks to receive instant updates whenever a user completes an offer and earns a reward. When an offer is completed, our server will send a notification to the configured callback URL. This callback provides the necessary information to process and verify the reward for the user in your application. [Learn more.](/offerwall-sdk/server-to-server-s2s-callback-configuration.md)

## 3. 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/sandbox-environment/sandbox-environment.md).
{% endhint %}

To ensure your OfferWall integration is working perfectly, follow these steps during the testing phase.

* Open the offerwall and verify that all offers are displayed correctly.
* Complete an offer and confirm that a callback is received from PubScale server to your server. For the sandbox environment, ensure the callback URL is configured properly to receive sandbox callbacks.
* Ensure the hashing technique used matches the one specified in the documentation.
* Verify that the reward value received matches the value displayed for the offer.
* Confirm that the callback is received only from PubScale's [whitelisted server IPs](/offerwall-sdk/s2s-callback-configuration/ip-whitelist.md).&#x20;


---

# 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://pubscale.gitbook.io/offerwall-sdk/basic-integration/ios.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.
