To work with the DT Offer Wall you must ensure that you have:
- Successfully set up your app,
- Integrated the DT Offer Wall via the SDK and implemented the APIs
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-ios
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:
OfferWall.userId = "userId"
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:
let GDPRDataUseConsent = OfferWallDataUseConsent.GDPR(.given)
OfferWall.setConsent(GDPRDataUseConsent)
OFWDataUseConsent *gdprConsent = [OFWDataUseConsentGDPR dataUseConsentGDPRWithConsent:OFWGDPRConsentGiven];
[OfferWall setConsent:gdprConsent];
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:
let CCPADataUseConsent = OfferWallDataUseConsent.CCPA(privacyString: "1YYN")
OfferWall.setConsent(CCPADataUseConsent)
OFWDataUseConsent *ccpaConsent = [OFWDataUseConsentCCPA dataUseConsentCCPAWithPrivacyString:"1YNN"];
[OfferWall setConsent:ccpaConsent];
Google Play’s Families Ads Program
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:
/*API parameter updated (from 3.42.0): virtualCurrencyStartOptions -> virtualCurrencySettings */
OfferWall.start(with: appIdText, delegate: self, virtualCurrencySettings: nil) { [self] error in }
/*API parameter updated (from 3.42.0): virtualCurrencyStartOptions -> virtualCurrencySettings */
[OfferWall startWithAppId:appId delegate:self virtualCurrencySettings:nil completion:^(OFWError * _Nullable error) {}];
The delegate needs to be defined and passed to the start API.
It will let the integration know when the Offer Wall is opened and closed so you can pause and resume your app accordingly. More information about these callbacks and how to show the Offer Wall here.
Showing the Offer Wall
To Show the Offer Wall simply use the following API:
OfferWall.show()
[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:
let showOptions = ShowOptions(closeOnRedirect: true, viewController: nil, animated: true, customParams: nil)
OfferWall.show(with: showOptions)
OFWShowOptions *options = [OFWShowOptions optionsWithCloseOnRedirect:YES viewController:nil animated:NO customParams:nil];
[OfferWall showWithOptions:options];
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:
let customParams = ["pub0": "tracking_value_0", "pub1": "tracking_value_1"]
let showOptions = ShowOptions(viewController: nil, customParams: customParams)
OfferWall.show(with: showOptions)
NSDictionary *customParams = @{@"pub0": @"tracking_value_0", @"pub1": @"tracking_value_1"};
OFWShowOptions *showOptions = [OFWShowOptions optionsWithViewController:self customParams:customParams];
[OfferWall showWithOptions: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:
OfferWall.show("placementId")
[OfferWall showWithPlacementId:@"placementId"];
Offer Wall Lifecycle Callbacks
As mentioned in the "Starting the SDK" section, you will need to set up a delegate 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:
class OfferWallListener: OfferWallDelegate {
func didShow(_ placementId: String?) {
// You can assume the Offer Wall is being displayed and pause your app
}
func didFailToShow(_ placementId: String?, error: OfferWallError) {
// This is not expected to take place.
// You can assume the Offer Wall is not being displayed and resume your app
}
func didDismiss(_ placementId: String?) {
// You can assume the Offer Wall is not being displayed and resume your app
}
}
@interface OfferWallListener: NSObject {
}
@end
@implementation OfferWallListener
- (void)didShow:(NSString * _Nullable)placementId {
// You can assume the Offer Wall is being displayed and pause your app
}
- (void)didFailToShow:(NSString * _Nullable)placementId error:(OFWError * _Nonnull)error {
// This is not expected to take place.
// You can assume the Offer Wall is not being displayed and resume your app
}
- (void)didDismiss:(NSString * _Nullable)placementId {
// You can assume the Offer Wall is not being displayed and resume your app
}
@end
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 implement a VirtualCurrencySettings object and pass it to the SDK start.
Virtual Currency Settings
The VirtualCurrencySettings holds the security token and a delegate that allows for the complete client side rewarding. You need to implement the callbacks:
func didReceive(_ response: VirtualCurrencyResponse)
{
let amount = response.deltaOfCoins
// reward users accordingly
}
func didFail(with errorResponse: VirtualCurrencyErrorResponse)
{
// something went wrong. Make sure the security token is correct
}
- (void)didReceiveResponse:(OFWVirtualCurrencyResponse *_Nonnull)response
{
double amount = [response deltaOfCoins];
// reward users accordingly
}
- (void)didFailWithError:(OFWVirtualCurrencyErrorResponse *_Nonnull)errorResponse
{
// something went wrong. Make sure the security token is correct
}
And start the Offer Wall with a security token and delegate:
/* Class name updated (from 3.42.0): VirtualCurrencyStartOptions -> VirtualCurrencySettings */
var vcSettings = VirtualCurrencySettings(securityToken: "security_token", delegate: self)
OfferWall.start(with: appId, delegate: self, virtualCurrencySettings: vcSettings) { [self] error in }
/* Class name updated (from 3.42.0): OFWVirtualCurrencyStartOptions -> OFWVirtualCurrencySettings */
OFWVirtualCurrencySettings *vcSettings = [OFWVirtualCurrencySettings optionsWithSecurityToken:@"security_token" delegate:self];
[OfferWall startWithAppId:appId delegate:self virtualCurrencySettings:vcSettings completion:^(OFWError * _Nullable error) {}];
Requesting Virtual Currency
For requesting Virtual Currency use the following API:
OfferWall.requestCurrency()
[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)
/* Class name updated (from 3.42.0): CurrencyRequestOptions -> VirtualCurrencyRequestOptions */
let options = VirtualCurrencyRequestOptions(currencyId: "currency_id", toastOnReward: false)
OfferWall.requestCurrency(withOptions: options)
/* Class name updated (from 3.42.0): OFWCurrencyRequestOptions -> OFWVirtualCurrencyRequestOptions */
OFWVirtualCurrencyRequestOptions *options = [OFWVirtualCurrencyRequestOptions optionsWithCurrencyId:@"currency_id" toastOnReward:NO];
[OfferWall requestCurrencyWithOptions: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:
func didReceive(_ response: VirtualCurrencyResponse)
{
let amount = response.deltaOfCoins
let currencyId = response.currencyId
let coinsEarned = response.currencyName
// reward users accordingly
}
- (void)didReceiveResponse:(OFWVirtualCurrencyResponse *_Nonnull)response
{
double amount = [response deltaOfCoins];
NSString *currencyId = [response currencyId];
NSString *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:
func didFail(with errorResponse: VirtualCurrencyErrorResponse)
{
// something went wrong. Make sure the security token is correct
let currencyId = errorResponse.currencyId;
let message = errorResponse.serverErrorMessage;
let error = errorResponse.error;
}
- (void)didFailWithError:(OFWVirtualCurrencyErrorResponse *_Nonnull)errorResponse
{
// something went wrong. Make sure the security token is correct
NSString *currencyId = errorResponse.currencyId;
NSString *message = errorResponse.serverErrorMessage;
OFWError *error = errorResponse.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 |
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. |
UNKNOWN_ERROR | The server returned an error that the SDK does not recognize. |