# Amazon Publisher Services

This article is for publishers who want to use the DT FairBid SDK to load and display ads from Amazon Publisher Services (APS).

APS currently supports the following [ad types](https://app.gitbook.com/s/8KSLu5HNiyDWpvGRZh7B/publishers/additional-resources/ad-types-and-specification):

* Banner
* Interstitial
* Rewarded

To integrate APS as a mediated ad network with DT:

* [Step 1: Retrieve APS Information](#step-1-retrieve-aps-information).
* [Step 2: Add APS as a mediated network](#step-2-add-aps-as-a-mediated-network).
* [Step 3: Initialize the APS SDK](#step-3-initialize-the-aps-sdk).
* [Step 4: Add the APS SDK to your integration](#step-4-add-the-aps-sdk-to-your-integration).
* [Step 5: Test your integration](#step-5-test-your-integration).

## Step 1: Retrieve APS Information

Before retrieving your APS information, complete the following tasks to create APS ad unit inventory to mediate with DT. For more information about how to create APS inventory, see the [APS Portal documentation](https://ams.amazon.com/webpublisher/uam/docs/aps-mobile/resources).

* Create an APS account.

{% hint style="info" %}
Amazon Publisher Services (APS) is an invitation-only program. To create an APS account, [request an invitation](https://aps.amazon.com/aps/contact-us/) from APS. Once approved, APS sends an invitation with instructions on creating your APS account.
{% endhint %}

* Add your app to the APS Portal.
* Add Slots for your app.
* Update your `App-ads.txt` file to include the APS Portal.

Once you have created APS inventory, locate the following information in the APS Portal. This information is required later in Step 2 to set up APS as a DT mediated network.

<table><thead><tr><th width="203.4765625">APS INFO</th><th>DESCRIPTION</th><th>RETRIEVAL INSTRUCTIONS</th></tr></thead><tbody><tr><td>Price Point Mapping</td><td>CSV file containing ad unit pricing.</td><td>Download CSV file. For more information about where to find the file, see the <a href="https://ams.amazon.com/webpublisher/uam/docs/aps-mobile/resources">APS Portal documentation</a>.</td></tr><tr><td><code>UUID</code></td><td>Unique ID assigned to your APS ad slot.</td><td>For more information about how to locate UUIDs, see the APS Portal documentation on <a href="https://ams.amazon.com/webpublisher/mdtb/mobile_apps%23/app/8588">UUIDs</a>.</td></tr></tbody></table>

## Step 2: Add APS as a Mediated Network

Before you add APS as a DT mediated network:

* Ensure that you have access to the APS Portal information you retrieved in [Step 1](#step-1-retrieve-aps-information).
* [Add your App](https://app.gitbook.com/s/LbREhkP3WlLtP6TNVZ2Q/app-management/adding-a-new-app/adding-an-app) using the DT Console.
* Ensure that you [set up a DT Placement](https://app.gitbook.com/s/LbREhkP3WlLtP6TNVZ2Q/app-management/setting-up-an-existing-app/setting-up-placements) for each APS ad type you want to mediate with DT.

To add APS as a DT mediated network:

1. Log in to the [DT Console](https://console.fyber.com/), and click **App Management**.
2. [Set up](https://app.gitbook.com/s/LbREhkP3WlLtP6TNVZ2Q/app-management/setting-up-an-existing-app/setting-up-mediated-networks) APS as a mediated network for your app using the APS Price Point CSV file you downloaded in [Step 1](#step-1-retrieve-aps-information).

{% hint style="info" %}
DT uses the price point mapping across your entire account. If you update your price points in APS, ensure that you upload an updated CSV file in the DT Console.
{% endhint %}

3. For each Placement that you want to mediate with DT, create an ad network instance for APS with the following settings:
   * Use the APS UUID you retrieved in [Step 1](#step-1-retrieve-aps-information) as the **Instance ID**.
   * Turn *off* the **Auto CPM** function. For more information about how to turn off **Auto CPM**, see [Auto CPM](https://app.gitbook.com/s/LbREhkP3WlLtP6TNVZ2Q/app-management/setting-up-an-existing-app/setting-up-instances#editing-an-instance).\
     For more information about how to add instances to a Placement, see [Setting Up Instances](https://app.gitbook.com/s/LbREhkP3WlLtP6TNVZ2Q/app-management/setting-up-an-existing-app/setting-up-instances).

## Step 3: Initialize the APS SDK

Initialize the APS SDK within your app so that DT can mediate your APS inventory:

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

### Initializing the APS SDK on Android

The following process is recommended for initializing the APS SDK in either Java or Kotlin implementations on the Android platform.

1. Start DT FairBid SDK with your DT `APP_ID`.

{% code title="Java" %}

```java
FairBid.start(<<APP_ID>>, activity);

```

{% endcode %}

{% code title="Kotlin" %}

```kotlin
FairBid.start(<<APP_ID>>, activity)

```

{% endcode %}

2. Start the APS SDK with the `APP_KEY` configured on your APS Portal.

{% code title="Java" %}

```java
AdRegistration.getInstance(<<APP_KEY>>, context);

```

{% endcode %}

{% code title="Kotlin" %}

```kotlin
AdRegistration.getInstance(<<APP_KEY>>, context)

```

{% endcode %}

3. Create an object that implements the `SlotLoader` interface, and register it to DT FairBid SDK with `APSAdapter.slotLoader`.
4. Implement a Banner ad callback to trigger whenever you call `Banner.show(placementId, activity)` for a placement configured with an APS instance in the waterfall.

{% code title="Java" %}

```java
loadAPSBannerSlot(String slotUUID, int width, int height))

```

{% endcode %}

{% code title="Kotlin" %}

```kotlin
loadAPSBannerSlot(slotUUID: String, width: Int, height: Int)

```

{% endcode %}

5. Implement an Interstitial ad callback to trigger whenever you call `Interstitiat.request(placementId)` for a placement configured with an APS instance in the waterfall.

{% code title="Java" %}

```java
loadAPSInterstitialSlot(String slotUUID)

```

{% endcode %}

{% code title="Kotlin" %}

```kotlin
loadAPSInterstitialSlot(slotUUID: String)

```

{% endcode %}

6. Implement a Rewarded ad callback to trigger whenever you call `Rewarded.request(placementId)` for a placement configured with an APS instance in the waterfall.

{% code title="Java" %}

```java
loadAPSRewardedSlot(String slotUUID)

```

{% endcode %}

{% code title="Kotlin" %}

```kotlin
loadAPSRewardedSlot(slotUUID: String)

```

{% endcode %}

7. Create an object that implements the `DTBAdCallback`.
8. Implement the `onSuccess` callback, and extract the following parameters and pass them back to FairBid via `APSAdapter.setBidInfo(slotUUID, encodedPricePoints, bidInfo)`:
   * Encoded price points
   * Bid info

{% code title="Java" %}

```java
onSuccess(@NonNull DTBAdResponse dtbAdResponse) {
    Log.d("APS", "onSuccess: " + slotUUID);
    String encodedPricePoints = SDKUtilities.getPricePoint(dtbAdResponse);
    String bidInfo = SDKUtilities.getBidInfo(dtbAdResponse);
    APSAdapter.setBidInfo(slotUUID, encodedPricePoints, bidInfo);

```

{% endcode %}

{% code title="Kotlin" %}

```kotlin
onSuccess(dtbAdResponse: DTBAdResponse) {
    Log.d("[APS] onSuccess: $slotUUID")
    val encodedPricePoints: String = SDKUtilities.getPricePoint(dtbAdResponse)
    val bidInfo = SDKUtilities.getBidInfo(dtbAdResponse)
    APSAdapter.setBidInfo(slotUUID, encodedPricePoints, bidInfo)

```

{% endcode %}

9. (Optional) Implement the `onFailure` callback to receive error messages when APS cannot fill a slot.

{% code title="Java" %}

```java
onFailure(@NonNull AdError adError) {
    Log.d("APS", "onFailure: Amazon APS error: " + adError.getMessage());

```

{% endcode %}

{% code title="Kotlin" %}

```kotlin
onFailure(adError: AdError) {
    Log.d("[APS] onFailure: Amazon APS error: ${adError.message}")

```

{% endcode %}

#### **Example: Android Implementation**

{% code title="Java" overflow="wrap" %}

```java
import android.content.Context;
import android.util.Log;

import androidx.annotation.NonNull;

import com.amazon.device.ads.AdError;
import com.amazon.device.ads.AdRegistration;
import com.amazon.device.ads.DTBAdCallback;
import com.amazon.device.ads.DTBAdRequest;
import com.amazon.device.ads.DTBAdResponse;
import com.amazon.device.ads.DTBAdSize;
import com.amazon.device.ads.SDKUtilities;
import com.fyber.FairBid;
import com.fyber.fairbid.adapters.APSAdapter;


// 3. Create object with slotLoader interface
public class AmazonAPS implements APSAdapter.SlotLoader {

    private static AmazonAPS INSTANCE = new AmazonAPS();

    private AmazonAPS() {}

    public static void start(String appKey, Context context) {
        // extra check to perform this only once
        if (!AdRegistration.isInitialized()) {
            // 2. Start APS SDK
            AdRegistration.getInstance(appKey, context);
            // 3. Register slotLoader to FairBid instance
            APSAdapter.setSlotLoader(INSTANCE);
        }
    }

    // 4. Load Banner Ad Type
    @Override
    public void loadAPSBannerSlot(@NonNull String slotUUID, int width, int height) {
        DTBAdRequest adRequest = new DTBAdRequest();
        adRequest.setSizes(new DTBAdSize(width, height, slotUUID));
        // 7. Implement callback
        adRequest.loadAd(new DTBAdCallback() {
                // 9. Implement onFailure
                @Override
                public void onFailure(@NonNull AdError adError) {
                    Log.d("APS", "onFailure: Amazon APS error: " + adError.getMessage());
                }
                // 8. Implement onSuccess callback
                @Override
                public void onSuccess(@NonNull DTBAdResponse dtbAdResponse) {
                    Log.d("APS", "onSuccess: " + slotUUID);
                    String encodedPricePoints = SDKUtilities.getPricePoint(dtbAdResponse);
                    String bidInfo = SDKUtilities.getBidInfo(dtbAdResponse);
                    APSAdapter.setBidInfo(slotUUID, encodedPricePoints, bidInfo);
                }
            });
        }
    }

    // 5. Load Interstitial Ad Type
    @Override
    public void loadAPSInterstitialSlot(@NonNull String slotUUID) {
        DTBAdRequest adRequest = new DTBAdRequest();
        adRequest.setSizes(new DTBAdSize.DTBInterstitialAdSize(slotUUID));
        // 7. Implement callback
        adRequest.loadAd(new DTBAdCallback() {
                // 9. Implement onFailure
                @Override
                public void onFailure(@NonNull AdError adError) {
                    Log.d("APS", "onFailure: Amazon APS error: " + adError.getMessage());
                }
                // 8. Implement onSuccess callback
                @Override
                public void onSuccess(@NonNull DTBAdResponse dtbAdResponse) {
                    Log.d("APS", "onSuccess: " + slotUUID);
                    String encodedPricePoints = SDKUtilities.getPricePoint(dtbAdResponse);
                    String bidInfo = SDKUtilities.getBidInfo(dtbAdResponse);
                    APSAdapter.setBidInfo(slotUUID, encodedPricePoints, bidInfo);
                }
            });
        }
    }

    // 6. Load Rewarded Ad Type
    @Override
    public void loadAPSRewardedSlot(@NonNull String slotUUID) {
        DTBAdRequest adRequest = new DTBAdRequest();
        adRequest.setSizes(new DTBAdSize.DTBVideo(320,480, slotUUID));
        // 7. Implement callback
        adRequest.loadAd(new DTBAdCallback() {
                // 9. Implement onFailure
                @Override
                public void onFailure(@NonNull AdError adError) {
                    Log.d("APS", "onFailure: Amazon APS error: " + adError.getMessage());
                }
                // 8. Implement onSuccess callback
                @Override
                public void onSuccess(@NonNull DTBAdResponse dtbAdResponse) {
                    Log.d("APS", "onSuccess: " + slotUUID);
                    String encodedPricePoints = SDKUtilities.getPricePoint(dtbAdResponse);
                    String bidInfo = SDKUtilities.getBidInfo(dtbAdResponse);
                    APSAdapter.setBidInfo(slotUUID, encodedPricePoints, bidInfo);
                }
            });
        }
    }

}


// ... inside your code
// 1. start DT FairBid SDK
FairBid.start("APP_ID", activity);
// and also start APS through the helper class above
AmazonAPS.start("APP_KEY", context);

```

{% endcode %}

{% code title="Kotlin" overflow="wrap" %}

```kotlin
import android.content.Context
import android.util.Log

import androidx.annotation.NonNull

import com.amazon.device.ads.AdError
import com.amazon.device.ads.AdRegistration
import com.amazon.device.ads.DTBAdCallback
import com.amazon.device.ads.DTBAdRequest
import com.amazon.device.ads.DTBAdResponse
import com.amazon.device.ads.DTBAdSize
import com.amazon.device.ads.SDKUtilities
import com.fyber.FairBid
import com.fyber.fairbid.adapters.APSAdapter

// 3. Create object with slotLoader interface
class AmazonAPS private constructor() : APSAdapter.slotLoader {

    companion object {
        private val instance: AmazonAPS by lazy {
            AmazonAPS()
        }

        fun start(appKey: String, context: Context) {
            // extra check to perform this only once
            if (!AdRegistration.isInitialized()) {
                // 2. Start APS SDK
                AdRegistration.getInstance(appKey, context)
                // 3. Register slotLoader to FairBid instance
                APSAdapter.slotLoader = instance
            }
        }

    }
    // 4. Load Banner Ad Type
    override fun loadAPSBannerSlot(slotUUID: String, width: Int, height: Int) {
        DTBAdRequest().apply {
            setSizes(DTBAdSize(width, height, slotUUID))
            // 7. Implement callback
            loadAd(object : DTBAdCallback {
                // 9. Implement onFailure
                override fun onFailure(adError: AdError) {
                    Log.d("[APS] onFailure: Amazon APS error: ${adError.message}")
                }
                //8. Implement onSuccess callback
                override fun onSuccess(dtbAdResponse: DTBAdResponse) {
                    Log.d("[APS] onSuccess: $slotUUID")
                    val encodedPricePoints: String = SDKUtilities.getPricePoint(dtbAdResponse)
                    val bidInfo = SDKUtilities.getBidInfo(dtbAdResponse)
                    APSAdapter.setBidInfo(slotUUID, encodedPricePoints, bidInfo)
                }
            })
        }
    }

    // 5. Load Interstitial Ad Type
    override fun loadAPSInterstitialSlot(slotUUID: String) {
        DTBAdRequest().apply {
            setSizes(DTBAdSize.DTBInterstitialAdSize(slotUUID))
            // 7. Implement callback
            loadAd(object : DTBAdCallback {
                // 9. Implement onFailure
                override fun onFailure(adError: AdError) {
                    Log.d("[APS] onFailure: Amazon APS error: ${adError.message}")
                }
                // 8. Implement onSuccess callback
                override fun onSuccess(dtbAdResponse: DTBAdResponse) {
                    Log.d("[APS] onSuccess: $slotUUID")
                    val encodedPricePoints: String = SDKUtilities.getPricePoint(dtbAdResponse)
                    val bidInfo = SDKUtilities.getBidInfo(dtbAdResponse)
                    APSAdapter.setBidInfo(slotUUID, encodedPricePoints, bidInfo)
                }
            })
        }
    }

    // 6. Load Rewarded Ad Type
    override fun loadAPSRewardedSlot(slotUUID: String) {
        DTBAdRequest().apply {
            setSizes(DTBAdSize.DTBVideo(320,480, slotUUID))
            // 7. Implement Callback
            loadAd(object : DTBAdCallback {
                // 9. Implement OnFailure
                override fun onFailure(adError: AdError) {
                    Log.d("[APS] onFailure: Amazon APS error: ${adError.message}")
                }
                // 8. Implement OnSuccess callback
                override fun onSuccess(dtbAdResponse: DTBAdResponse) {
                    Log.d("[APS] onSuccess: $slotUUID")
                    val encodedPricePoints: String = SDKUtilities.getPricePoint(dtbAdResponse)
                    val bidInfo = SDKUtilities.getBidInfo(dtbAdResponse)
                    APSAdapter.setBidInfo(slotUUID, encodedPricePoints, bidInfo)
                }
            }
        })
    }
}


// ... inside your code
// 1. Start DT FairBid SDK
FairBid.start(APP_ID, activity)
// and also start APS through the helper class above
AmazonAPS.start(APP_KEY, context)

```

{% endcode %}
{% endtab %}

{% tab title="iOS" %}

### Initializing the APS SDK on iOS

The following process is recommended for initializing the APS SDK in Objective–C implementations on the iOS platform.

1. Start the FairBid SDK.

{% code title="Objective-C" %}

```objectivec
+ [FairBid startWithAppId:options:]

```

{% endcode %}

2. Start the APS SDK with the `APP_KEY` from the APS Portal.

{% code title="Objective-C" %}

```objectivec
- [DTBAds setAppKey:<<APP_KEY>>];

```

{% endcode %}

3. Create an object that conforms to the `id <FYBAPSSlotLoader>` protocol, and assign it to the `[FairBid apsAdapter].slotLoader` property.
4. Implement a Banner ad callback to trigger whenever you call `+ [FYBBanner showBannerInView:position:options:]` for a placement with an APS instance in the waterfall.

{% code title="Objective-C" %}

```objectivec
-loadAPSBannerSlot:width:height:

```

{% endcode %}

5. Implement a Rewarded ad callback to trigger whenever you call `+ [FYBRewarded request:placementId]` for a placement with an APS instance in the waterfall.

{% code title="Objective-C" %}

```objectivec
-loadAPSRewardedSlot:(NSString *)slotUUID

```

{% endcode %}

6. Implement a Interstitial ad callback to trigger whenever you call `+ [FYBInterstitial request:placementId]` for a placement with an APS instance in the waterfall.

{% code title="Objective-C" %}

```objectivec
-loadAPSInterstitialSlot:(NSString *)slotUUID

```

{% endcode %}

#### **Example: iOS Ad Slot Loader**

{% code title="Objective-C" overflow="wrap" %}

```objectivec
- (void)loadAPSBannerSlot:
            (nonnull NSString *)slotUUID
                    width:(NSInteger)width
                   height:(NSInteger)height {
  NSLog(@"[APS] loadAPSBannerSlot: %@, width: "
        @"%li, height: %li",
        slotUUID, (long)width, (long)height);
  DTBAdNetworkInfo *networkInfo =
      [[DTBAdNetworkInfo alloc]
          initWithNetworkName:
              DTBADNETWORK_CUSTOM_MEDIATION];
  DTBAdLoader *loader = [[DTBAdLoader alloc]
      initWithAdNetworkInfo:networkInfo];
  DTBAdSize *size = [[DTBAdSize alloc]
      initBannerAdSizeWithWidth:width
                       height:height
                  andSlotUUID:slotUUID];
  if (!size) {
    NSLog(@"[APS] Failed to create DTBAdSize "
          @"object: (width: %li, height: %li, "
          @"andSlotUUID: %@)",
          (long)width, (long)height, slotUUID);
    return;
  }
  [loader setAdSizes:@[ size ]];
  [loader loadAd:self];
}

// 5. Load Rewarded ad type callback
- (void)loadAPSRewardedSlot:(NSString *)slotUUID {
    NSLog(@"[APS] loadAPSRewardedSlot: %@", slotUUID);

    DTBAdNetworkInfo *networkInfo = [[DTBAdNetworkInfo alloc] initWithNetworkName:DTBADNETWORK_CUSTOM_MEDIATION];
    DTBAdLoader *loader = [[DTBAdLoader alloc] initWithAdNetworkInfo:networkInfo];
    DTBAdSize *size = [[DTBAdSize alloc] initVideoAdSizeWithPlayerWidth:320 height:480 andSlotUUID:slotUUID];
    [loader setAdSizes:@[size]];
    [loader loadAd:self];
}

// 6. Load Interstitials ad type callback
- (void)loadAPSInterstitialSlot:
    (NSString *)slotUUID {
    NSLog(@"[APS] loadAPSInterstitialSlot: %@", slotUUID);

    DTBAdNetworkInfo *networkInfo = [[DTBAdNetworkInfo alloc] initWithNetworkName:DTBADNETWORK_CUSTOM_MEDIATION];
    DTBAdLoader *loader = [[DTBAdLoader alloc] initWithAdNetworkInfo:networkInfo];
    DTBAdSize *size = [[DTBAdSize alloc] interstitialAdSizeWithSlotUUID:slotUUID];
    [loader setAdSizes:@[size]];
    [loader loadAd:self];
}

```

{% endcode %}

7. Create object that conforms to `id <DTBAdCallback>` protocol.
8. Implement the `-onSuccess:` callback, and pass the following parameters back to FairBidSDK by calling `-[[FairBid apsAdapter] setBidInfo:encodedPricePoint:slotUUID:]`.

* `adResponse.bidInfo`
* `adResponse.amznSlots`
* `adResponse.adSize.slotUUID`

9. (Optional) Implement the `-onFailure:` callback to receive error messages when APS cannot fill a slot.

#### **Example: iOS Ad Callbacks**

{% code title="Objective-C" overflow="wrap" %}

```objectivec
// 7. DTBAdCallback
// 8. onSuccess callback
- (void)onSuccess:(DTBAdResponse *)adResponse {
    NSLog(@"[APS] onSuccess: %@", adResponse);
    [[FairBid apsAdapter] setBidInfo:adResponse.bidInfo
                   encodedPricePoint:adResponse.amznSlots
                            slotUUID:adResponse.adSize.slotUUID];
}

// 9. onFailure callback
- (void)onFailure:(DTBAdError *)error {
    NSLog(@"[APS] onFailure: %@", error);
}

```

{% endcode %}
{% endtab %}

{% tab title="Unity" %}

### Initializing the APS SDK on Unity

The following process is recommended for initializing the APS SDK on the Unity platform.

1. Add the following dependencies to `mainTemplate.gradle`:

{% code title="Gradle" %}

```groovy
implementation 'com.amazon.android:aps-sdk:9.9.2'
implementation 'androidx.appcompat:appcompat:1.6.1'
compileOnly 'com.fyber:fairbid-sdk:3.55.0'
```

{% endcode %}

{% hint style="info" %}
**Note**

FairBid is already added as a dependency; however, to access the APIs from the unityLibrary project, add them as a compileOnly dependency.
{% endhint %}

2. To avoid conflicts with duplicate entries for `META-INF/com.android.tools/proguard/coroutines.pro`, add the following code to `launcherTemplate.gradle`:

{% code title="Gradle" %}

```groovy
android {
    packagingOptions {
        exclude 'META-INF/com.android.tools/proguard/coroutines.pro'
    }
}
```

{% endcode %}

3. If your minimum API level is below 19, add the following snippet to `LauncherManifest.xml`:

{% code title="XML" %}

```xml
<uses-sdk tools:overrideLibrary="com.amazon.aps.ads" />

```

{% endcode %}

4. Create the `Assets/APS Compat` directory, and add `AmazonAPS.java` (provided below) to the directory.

{% code title="Java" overflow="wrap" %}

```java
package com.fyber.aps.compat;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.util.Log;

import com.amazon.device.ads.AdError;
import com.amazon.device.ads.AdRegistration;
import com.amazon.device.ads.DTBAdCallback;
import com.amazon.device.ads.DTBAdRequest;
import com.amazon.device.ads.DTBAdResponse;
import com.amazon.device.ads.DTBAdSize;
import com.amazon.device.ads.SDKUtilities;
import com.fyber.fairbid.adapters.APSAdapter;

import androidx.annotation.NonNull;


public class AmazonAPS implements APSAdapter.SlotLoader {

    private static AmazonAPS INSTANCE = new AmazonAPS();

    private AmazonAPS() {
    }

    public static void start(String appKey, Context context) {
        // extra check to perform this only once
        if (!AdRegistration.isInitialized()) {
            AdRegistration.getInstance(appKey, context);
            APSAdapter.setSlotLoader(INSTANCE);
        }
    }

    @Override
    public void loadAPSBannerSlot(@NonNull String slotUUID, int width, int height) {
        DTBAdRequest adRequest = new DTBAdRequest();
        adRequest.setSizes(new DTBAdSize(width, height, slotUUID));
        adRequest.loadAd(new DTBAdCallback() {
            @Override
            public void onFailure(@NonNull AdError adError) {
                Log.d("APS", "onFailure: Amazon APS error: " + adError.getMessage());
            }

            @Override
            public void onSuccess(@NonNull DTBAdResponse dtbAdResponse) {
                Log.d("APS", "onSuccess: " + slotUUID);
                String encodedPricePoints = SDKUtilities.getPricePoint(dtbAdResponse);
                String bidInfo = SDKUtilities.getBidInfo(dtbAdResponse);
                APSAdapter.setBidInfo(slotUUID, encodedPricePoints, bidInfo);
            }
        });
    }


    @Override
    public void loadAPSInterstitialSlot(@NonNull String slotUUID) {
        DTBAdRequest adRequest = new DTBAdRequest();
        adRequest.setSizes(new DTBAdSize.DTBInterstitialAdSize(slotUUID));
        adRequest.loadAd(new DTBAdCallback() {
            @Override
            public void onFailure(@NonNull AdError adError) {
                Log.d("APS", "onFailure: Amazon APS error: " + adError.getMessage());
            }

            @Override
            public void onSuccess(@NonNull DTBAdResponse dtbAdResponse) {
                Log.d("APS", "onSuccess: " + slotUUID);
                String encodedPricePoints = SDKUtilities.getPricePoint(dtbAdResponse);
                String bidInfo = SDKUtilities.getBidInfo(dtbAdResponse);
                APSAdapter.setBidInfo(slotUUID, encodedPricePoints, bidInfo);
            }
        });
    }

    @Override
    public void loadAPSRewardedSlot(@NonNull String slotUUID) {
        DTBAdRequest adRequest = new DTBAdRequest();
        adRequest.setSizes(new DTBAdSize.DTBVideo(320, 480, slotUUID));
        adRequest.loadAd(new DTBAdCallback() {
            @Override
            public void onFailure(@NonNull AdError adError) {
                Log.d("APS", "onFailure: Amazon APS error: " + adError.getMessage());
            }

            @Override
            public void onSuccess(@NonNull DTBAdResponse dtbAdResponse) {
                Log.d("APS", "onSuccess: " + slotUUID);
                String encodedPricePoints = SDKUtilities.getPricePoint(dtbAdResponse);
                String bidInfo = SDKUtilities.getBidInfo(dtbAdResponse);
                APSAdapter.setBidInfo(slotUUID, encodedPricePoints, bidInfo);
            }
        });
    }
}
```

{% endcode %}

5. Open the Unity Inspector, and check **Android** on the **Select platforms for plugin** pane.

<div align="left" data-with-frame="true"><img src="https://2654615282-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4IftQ9WUOy9feTA5sZeE%2Fuploads%2FYcShsL0OyH2cO8qmjNQP%2Fimage.png?alt=media&#x26;token=00df8532-f79a-4d06-8d03-f50ee5e2c838" alt=""></div>

<br>

6. Start APS by adding the `start` call inside any of your methods in the C#. For example, you can add it right after starting FairBid.

{% code title="C#" overflow="wrap" %}

```csharp
AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
AndroidJavaClass jc = new AndroidJavaClass("com.fyber.aps.compat.AmazonAPS");
jc.CallStatic("start", "YOUR APP KEY HERE", activity);

```

{% endcode %}

7. Build and run your app.
   {% endtab %}
   {% endtabs %}

## Step 4: Add the APS SDK to your Integration

To integrate the <code class="expression">page.vars.fb\_sdk\_name</code> SDK, follow the instructions on the [Supported Networks](https://docs.digitalturbine.com/dt-fairbid/fairbid-sdk/supported-networks) page.

## Step 5: Test Your Integration

Use the DT Test Suite to verify that you have set up your app properly for FairBid mediation. The DT Test Suite is available for Android, iOS, and Unity apps. For more information about using the DT Test Suite, see [Test Suite](https://docs.digitalturbine.com/dt-fairbid/fairbid-sdk/tools/test-suite).

<div align="left" data-with-frame="true"><img src="https://2654615282-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4IftQ9WUOy9feTA5sZeE%2Fuploads%2FoqWJTBXcQ0oynphWzkiP%2FIMG_4982_copy%20(2).jpg?alt=media&#x26;token=24ad859d-8e24-4307-ba67-a2c908893584" alt="" width="188"></div>
