> For the complete documentation index, see [llms.txt](https://docs.ayetstudios.com/v/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ayetstudios.com/v/product-docs/offerwall/sdk-integrations-deprecated/ios-sdk.md).

# iOS SDK

{% hint style="info" %}

### Updates History

**2024-08-02: v1.7.2** - Updated documentation to replace plist.info new Xcode 13 Info settings, and add up-to-date Xcode screenshots.

**2020-08-11: v1.7.1** - Updated documentation to introduce new parameters to differentiate chargebacks from conversions&#x20;

**2020-07-29: v1.7** - Updated iOS SDK to xcframework, support for Xcode 12, Swift 5.x, iOS 11+, dropped ARMv7 support&#x20;

**2019-10-20: v1.6** - Updated iOS SDK to Xcode 11, iOS 13 SDK, Swift 5.1, full binary support&#x20;

**2019-07-19: v1.5** - Updated iOS SDK with adslot changes, recompiled with Swift 5, re-added x86\_64 (simulator) support&#x20;

**2018-09-29: v1.4.2** - Updated iOS SDK to Xcode 10 and Swift 4.2, stripped debug symbols&#x20;

**2018-07-09: v1.4.1** - Removed Simulator Code from iOS SDK, fixed iTunes validation issues with Xcode 9+&#x20;

**2018-05-07: v1.4** - Framework recompiled with Swift 4.1&#x20;

**2018-03-08: v1.3** - You are able to use logs now in order to locate implementation problems&#x20;

**2018-01-20: v1.2** - Added functions that provide current user balances&#x20;

**2017-12-06: v1.0** - Initial Release of our Publisher SDK (iOS)
{% endhint %}

## Eligible Placement & AdSlot Combinations <a href="#eligible-placement-and-adslot-combinations" id="eligible-placement-and-adslot-combinations"></a>

The below table shows all Placement & AdSlot Type combinations that allow you to utilize the Android SDK integration.

| Placement Type | AdSlot Type | Eligible Integration Type |
| -------------- | ----------- | ------------------------- |
| iOS App        | Offerwall   | iOS SDK                   |

{% hint style="danger" %}
If you integrate the iOS SDK while using a different Placement & AdSlot combination in the ayeT-Studios dashboard, you won't be able to initialize the Offerwall.
{% endhint %}

## Getting Started

Before you start with the integration, make sure you have:

* [x] Created an Adslot
* [x] Added a Placement
* [x] Added an AdSlot

You will find more details here:

{% content-ref url="/pages/W7CE6bNya8L7RoaXXY21" %}
[Dashboard Setup](/v/product-docs/dashboard-setup.md)
{% endcontent-ref %}

{% hint style="info" %}
Make sure to use the correct package name that you intend to use for your final app.

Or create a test placement with a different package name that matches the package name of your test app.

If package name of your placement and your actuall app don't match, you can't initialize the Offerwall.
{% endhint %}

## Download the Library

You can download the lastest version of our publisher library here:

{% file src="/files/80t56vv5APs1HC0FM72G" %}

## Add the library to your Xcode project <a href="#add-the-library-to-your-xcode-project" id="add-the-library-to-your-xcode-project"></a>

Unzip the downloaded xcframework archive file, preferably somewhere in your project root.

Navigate to your project root in the Project Navigator, select **General** tab and then expand **Frameworks, Libraries, and Embedded Content**.

Click on the **+** sign and add the archive to your project (using select files), then make sure the Embed option is set to *Embed & Sign*. The final configuration should look like this:

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

Then, still in your project root in the Project Navigator, select **Info** tab and expand **Custom iOS Target Properties**. Right click and select **Add Row**, and add **App Transport Security Settings**. Then click on the newly added row, select **Add Row** again, and add the **Allow Arbitrary Loads** option. Make sure this is set to **YES**:

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

## Initialize the SDK & Managed User Balances <a href="#initialize-the-sdk-and-managed-user-balances" id="initialize-the-sdk-and-managed-user-balances"></a>

You'll need to initialize ayeT SDK before being able to use it. A good place to do this is the application:didFinishLaunchingWithOptions: method in your application delegate:

```swift
import AyetStudiosSDK
[...]
AyetSdk.sdkInit(appKey: "<your placement identifier from our dashboard>" , userIdentifier: "username (external identifier)" , callback: { available_currency , pending_currency , spent_currency in
    print("Available currency:  \(available_currency)")
    print("Pending currency:    \(pending_currency)")
    print("Spent currency:      \(spent_currency)")
});
```

If you want to spend user currency, for example if the user clicks a button assigned to a **purchaseInAppItem** function, you can utilize the **deductBalance** function:

```swift
@IBAction func purchaseInAppItem(_ sender: Any) {

    let deductAmount = 5

    AyetSdk.deductBalance(amount: deductAmount , deductCallback: {callback in

        if (callback.caseInsensitiveCompare("success") == .orderedSame) {
            print("Deduct response is successful");
            // TODO: activate the purchased content
        }
        else {
            print("Deduct response is unsuccessful");
            // this usually means that the user does not have sufficient balance in his account
        }
    })

}	         
```

{% hint style="info" %}
The status string will be "success" if the balance deduction was successful or "failed" if something went wrong (e.g. insufficient user balance).
{% endhint %}

{% hint style="warning" %}
**Attention:** The username or external identifier passed in the init call (e.g. username, hashed email address, etc.) will be accessible in the conversion callbacks through the *{external\_identifier}* parameter.
{% endhint %}

## Check User Balances (Managed Currency Handling) <a href="#check-user-balances-managed-currency-handling" id="check-user-balances-managed-currency-handling"></a>

After initializing the SDK, you can check the current user balances anywhere in your code:

```swift
AyetSdk.getAvailableCurrency();

AyetSdk.getPendingCurrency();

AyetSdk.getSpentCurrency();	  
```

## Show the Offerwall

Showing the offerwall is straight-forward, you can simply call **showOfferwall** from your UIViewController:

```swift
/AyetSdk.showOfferwall(currentController: self, adslotName: "my offerwall adslot name");	  
```

{% hint style="info" %}
**showOfferwall** starts our offerwall activity for the given adslot and displays available tasks for the user to complete.
{% endhint %}

## Logs

If you want to see logs in Xcode debug area, simply call **sdkLogEnable** before initializing sdk.

```swift
AyetSdk.sdkLogEnable();	  
```

## Conversion Callbacks & Currency Handling <a href="#conversion-callbacks-and-currency-handling" id="conversion-callbacks-and-currency-handling"></a>

Learn about:

* Setting up callbacks
* IP Whitelists
* Securing callbacks using HMAC Security Hash
* Testing callbacks

Click on the link below:

{% content-ref url="/pages/5sxVWIW1fto5Mmv1JxeJ" %}
[Callbacks & Testing](/v/product-docs/callbacks-and-testing.md)
{% endcontent-ref %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.ayetstudios.com/v/product-docs/offerwall/sdk-integrations-deprecated/ios-sdk.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
