Unity Plugin APIs

To work with the DT Offer Wall you must ensure that you have:

DT Offer Wall Sample App

If you prefer to jump straight to the code DT's sample app can assist you in using DT Offer Wall within your app. In addition, use the DT sample app as a reference during implementation to troubleshoot possible integration issues.

https://github.com/fyber-engineering/offerwall-sample-app-unity

Before Starting the SDK

User Id

DT Offer Wall SDK will generate a unique user ID upon starting the SDK.
If instead you want to provide the SDK with your own user id, you will need to use the following API before starting the SDK:

C#
OfferWall.UserId = "userId";

The user id is stored across SDK sessions.
This API can be called at any point after starting the SDK. Any future action by the user will be associated with the new user id.

Privacy and compliance

GDPR

The General Data Protection Regulation requires you to scope your user's consent. For more information on GDPR, click here.
A user is within the GDPR scope for your app when one or all of the following apply:

  • The user is currently located in the EU
  • The user has registered with the app as an EU resident
  • The app is specifically targeted to EU users

Once you have collected the user’s consent, you can pass it onto the SDK using the following API:

C#
OfferWall.SetConsent(new OfferWallPrivacyConsent.Gdpr(true));

We recommend that the first time you gather the user’s consent, you pass it onto the SDK before starting the SDK. The SDK will then take the user’s consent into consideration when initializing. In the following sessions, you will only need to call the API if the user updates his or her consent.
More information on GDPR can be found under the GDPR Resource Page and FAQs.

CCPA

The intention of the California Consumer Privacy Act of 2018 (CCPA) is to protect the personal information of California residents. CCPA applies to all companies doing business in California. If a California resident uses an app developer’s mobile app, CCPA applies to the developer and every company that processes the personal information of the app’s users.
CCPA came into effect on 1 January 2020.

For more information on DT and CCPA, refer to DT’s CCPA Resource Page.
For more information about CCPA, refer to the IAB CCPA Compliance Framework.

Once you have collected the user’s opt-out, you can pass it onto the SDK using the following API:

C#
OfferWall.SetConsent(new OfferWallPrivacyConsent.Ccpa("1YNN"));

Google Play’s Families Ads Program (Android only)

If you want to achieve full compliance with Google Family Program you will need to let the SDK know that it should not track the google Ad ID in any of its requests for each and every user for which the Google Family Program applies. More information here.

To achieve this, you will need to pass an optional boolean parameter when starting the SDK (see below).

Starting the SDK

Before showing the Offer Wall or requesting virtual currency you will need to start the SDK using the following API:

C#
OfferWall.StartSDK(appId: "appId");

In order to let the integration know when the Offer Wall is opened and closed so you can pause and resume your app accordingly you need to implement our lifecycle callbacks.

Optional Starting parameters

Google Play’s Families Ads Program (Android only)

By default, the DT Offer Wall SDK will send the Google Ad ID in all communications to our backend.
To prevent that, in alignment with Google Family Program, you can pass an extra optional boolean when starting the SDK:

C#
OfferWall.StartSDK(appId: "appId", disableAdvertisingId: true);

Showing the Offer Wall

To Show the Offer Wall simply use the following API:

C#
OfferWall.Show();

This will show the Offer Wall for the default placement with the default behavior (keep the Offer Wall open when the user clicks on an offer and gets redirected out of your app).

Show Options

If you want to specify the placement ID, change the default behavior of the Offer Wall or introduce tracking parameters you can use ‘Show Options’

Close on Redirect

You can specify whether the Offer Wall should be closed once a user clicks on an offer. This will determine what the user sees when returning back to the app: either the Offer Wall again or your app.
By default, this value is false meaning the user will come back to the Offer Wall.
Use the following API to define the desired behavior:

C#
OfferWallShowOptions showOptions = new OfferWallShowOptions(closeOnRedirect: true);
OfferWall.Show(offerWallShowOptions: showOptions);

Custom parameters (server side rewarding)

When using server side rewarding (see Integrating via REST API - Rewards), you may want to associate additional parameters to the Offer Wall being shown for a given user/placement so that you can perform additional tracking. These custom parameters will be passed back to your system during the reward callback.
Note that these parameters’ keys are limited to pub0, pub1, ... , pub9

To add these custom parameters when showing the Offer Wall, using the following API:

C#
var customParams = new Dictionary<string, string>
        {
            { "pub0", "tracking_value_0" },
            { "pub1", "tracking_value_1" }
        };
OfferWallShowOptions showOptions = new OfferWallShowOptions(customParams: customParams);
OfferWall.Show(offerWallShowOptions: showOptions);

Show With Placement ID

If you’re using placements in your integration, you can specify for which placement ID you want to show the Offer Wall:

C#
OfferWall.Show(placementId: "placementId");

Offer Wall Lifecycle Callbacks

As mentioned in the "Starting the SDK" section, you will need to set up a listener to be notified of Offer Wall lifecycle events:

  • Offer Wall is about to be shown
  • User closed the Offer Wall
  • Offer Wall was closed unexpectedly due to an error

This is how you implement the listener:

C#
OfferWall.OfferWallShownEvent += OnOfwShown;
OfferWall.OfferWallClosedEvent += OnOfwClosed;
OfferWall.OfferWallFailedToShowEvent += OnOfwFailedToShow;

Where the events comply to the following delegates (in the same order):

C#
public delegate void OfferWallShownCallback(string? placementId);
public delegate void OfferWallClosedCallback(string? placementId);
public delegate void OfferWallFailedToShowCallback(string? placementId, OfferWallError error);

Check the "Errors" section to assess which problem took place (typically an integration mistake).

Rewarding the User

If you are interested in using your own server to handle virtual rewards to your users, DT can interact with it after you've set up your own server.

Click here for more details on Server-Side Hosting.

The section below assumes you do not run your own servers and you prefer to rely on DT's virtual currency hosting. This is the default setting for mobile applications in the developer Dashboard.

You will first need to pass a security token to the SDK start as well as set up the respective virtual currency delegates:

C#
OfferWall.VirtualCurrencyResponseEvent += OnVirtualCurrencySuccess;
OfferWall.VirtualCurrencyErrorEvent += OnVirtualCurrencyError;

Where the events comply to the following delegates (in the same order)

C#
public delegate void VirtualCurrencyResponseHandler(VirtualCurrencySuccessfulResponse response);
public delegate void VirtualCurrencyErrorHandler(VirtualCurrencyErrorResponse response);

OfferWall.StartSDK(appId: "appId", token: "secret_token");

Requesting Virtual Currency

For requesting virtual currency use the following API:

C#
OfferWall.RequestCurrency();

This will request the server for the delta (amount since last transaction) of default virtual currency the current user is eligible for.

Virtual Currency Options

The request can be additionally configured in order to:

  • Specify the currency ID you want to request for (in case you are using multiple currencies in your app)
  • Specify whether the SDK should show a Toast to the user notifying them of the amount of virtual currency received. (it is shown by default)
C#
VirtualCurrencyRequestOptions options = new VirtualCurrencyRequestOptions(toastOnReward: true, currencyId: "currency_id");
OfferWall.RequestCurrency(options);

Handling Virtual Currency Success response

You can extract the delta of coins received by the user as well as the currency name and id from the the VirtualCurrencySuccessfulResponse object:

C#
public void OnVirtualCurrencySuccess(VirtualCurrencySuccessfulResponse response)
{
    double amountReceived = response.DeltaOfCoins;
    string currencyId = response.CurrencyId;
    string coinsEarned = response.CurrencyName;
    // reward users accordingly
}

Virtual Currency Error

When there is a problem with the request you can assess what’s wrong by inspecting the VirtualCurrencyErrorResponse object:

C#
public void OnVirtualCurrencyError(VirtualCurrencyErrorResponse virtualCurrencyError)
{
    // something went wrong. Make sure the security token is correct
    string currencyId = virtualCurrencyError.CurrencyId;
    string message = virtualCurrencyError.ServerErrorMessage;
    OfferWallError error = virtualCurrencyError.Error;
}

Errors

Some issues may arise when either showing the Offer Wall or requesting virtual currency.

Here is a list of the possible errors:

Error Description
SDK_NOT_STARTED You are trying to show the Offer Wall before starting the SDK.
CONNECTION_ERROR It can occur when either showing the Offer Wall or requesting virtual currency when the device is offline.
INVALID_VIRTUAL_CURRENCY_RESPONSE If the virtual currency request is successful but it’s not the expected format. This may be a consequence of an integration mistake or a problem in the system. If it occurs, please contact an account manager or Solution Engineer.
INVALID_VIRTUAL_CURRENCY_RESPONSE_SIGNATURE If the virtual currency response is incorrectly signed. This may indicate either an interference with the SDK<>backend communication (e.g., man in the middle) or a system problem. Please contact an account manager or solution engineer if you detect this error in production.
VIRTUAL_CURRENCY_SERVER_RETURNED_ERROR This typically indicates the backend rejected the virtual currency request due to missing parameters or a wrong signature. Double check your integration. If the problem persist, contact an account manager or Solution engineer.
SECURITY_TOKEN_NOT_PROVIDED If you call the request virtual currency API but you didn’t set a security token when Starting the SDK. This feedback will only take place on Android. On iOS, you will get a VIRTUAL_CURRENCY_SERVER_RETURNED_ERROR.
DEVICE_NOT_SUPPORTED Android Only: If you are trying to run the SDK on a device running Android OS lower than 4 (API 16 - Jelly Bean).
UNKNOWN_ERROR The server returned an error that the SDK does not recognize.

Back to Top ⇧