Banner Ads
After creating placements in the DT Console, add the following code snippets in the chosen context of your app. Access the Placement ID by using the copy button next to the placement name. For more information about creating placements in the DT Console, read here.
Banners are rectangle ads appearing either at the top or bottom of the screen when the user interacts with your app. The user can view them but cannot dismiss them. Banners are automatically refreshed by the DT FairBid SDK after a specified period of time.
The DT FairBid SDK refreshes banners automatically. To avoid discrepancies with DT's and 3rd-party network's reporting, any automatic or manual banner refresh settings on 3rd-party network SDKs must be disabled.
Showing a Banner
Implement the code below to show a Banner
string placementId = "1234";
Banner.Show(placementId);
Providing Banner Position
You can show your banner at the top or bottom of your screen. By default, the banner will be placed at the bottom of the screen.
If you want to change this behavior, use the following code:
string placementId = "1234";
BannerOptions bannerOptions = new BannerOptions();
bannerOptions.DisplayAtTheTop();
Banner.Show(placementId, bannerOptions);
Hiding the Banner
If you want to hide the banner temporarily, implement the code below:
string placementId = "1234";
Banner.Hide(placementId);
Destroying the Banner
Once you have decided that you no longer want to use the banner you can remove it entirely:
string placementId = "1234";
Banner.Destroy(placementId);
Adding Callbacks
The callback code below is required for the SDK to properly track the activity of your ad:
public class MyBannerListener : BannerListener
{
public void OnError(string placementId, string error)
{
// Called when an error from placement 'placementId' arises when loading an ad
}
public void OnLoad(string placementId)
{
// Called when an ad from placement 'placementId' is loaded
}
public void OnShow(string placementId, ImpressionData impressionData)
{
// Called when banner from placement 'placementId' shows up
}
public void OnClick(string placementId)
{
// Called when banner from placement 'placementId' is clicked
}
public void OnRequestStart(string placementId)
{
// Called when a banner from placement 'placementId' is going to be requested
}
}
Banner.SetBannerListener(new MyBannerListener());
Interstitial Ads
After creating placements in the DT Console, add the following code snippets in the chosen context of your app. Access the Placement ID by using the copy button next to the placement name. For more information about creating placements in the DT Console, read here.
Interstitials are either static or video ads presented before, during or after the user interacts with your app.
The user can view and then immediately dismiss them. This is a non-rewarded format for the user.
The speed and stability of users internet connections may vary. It is highly recommended to fetch as much in advance of showing an ad as possible. This helps to ensure that all necessary assets are downloaded. For example, you may want to fetch an ad when a level starts or after a previous ad has been shown.
Making the Request
Below is an example of making a request for an Interstitial.
Requesting the Interstitial
string placementId = "1234";
Interstitial.Request(placementId);
Adding Callbacks
The callback code below is required for the SDK to properly track the activity of your ad.
public class MyInterstitialListener : InterstitialListener
{
public void OnShow(string placementId, ImpressionData impressionData)
{
// Called when an Interstitial from placement 'placementId' shows up. In case the ad is a video, audio play will start here.
// On Android, this callback might be called only once the ad is closed.
}
public void OnClick(string placementId)
{
// Called when an Interstitial from placement 'placementId' is clicked
}
public void OnHide(string placementId)
{
// Called when an Interstitial from placement 'placementId' hides.
}
public void OnShowFailure(string placementId, ImpressionData impressionData)
{
// Called when an error arises when showing an Interstitial from placement 'placementId'
}
public void OnAvailable(string placementId)
{
// Called when an Interstitial from placement 'placementId' becomes available
}
public void OnUnavailable(string placementId)
{
// Called when an Interstitial from placement 'placementId' becomes unavailable
}
public void OnRequestStart(string placementId)
{
// Called when an Interstitial from placement 'placementId' is going to be requested
}
}
Interstitial.SetInterstitialListener(new MyInterstitialListener());
Example Showing an Ad
The following example checks to see if a placement is available and if it is, uses the show request to display the ad.
Important
If your game needs to be paused before showing an ad (e.g., stop audio playback), this is the best moment to do so.
The time between calling this API and the ad actually being shown should be negligible.
This approached is preferable compared to relying on the 'OnShow' callback since on Android, we cannot guarantee it will be called before the ad starts playing.
Showing an Ad
string placementId = "1234";
if (Interstitial.IsAvailable(placementId)) {
Interstitial.Show(placementId);
}
Rewarded Ads
After creating placements in the DT Console, add the following code snippets in the chosen context of your app. Access the Placement ID by using the copy button next to the placement name. For more information about creating placements in the DT Console, read here.
Rewarded ads are an engaging ad format that shows a short video ad to the user and in exchange the user will earn a reward. The user must consent and watch the video completely through to the end in order to earn the reward.
The speed and stability of users internet connections may vary. It is highly recommended to fetch as far in advance of showing an ad as possible. This helps to ensure that all necessary assets are downloaded. For example, you may want to fetch an ad when a level starts, or after a previous ad has been shown.
Make an Ad Request
The following example shows how to make a request to display the Rewarded ads.
Requesting a Rewarded Ad
string placementId = "1234";
Rewarded.Request(placementId);
Adding Callbacks
The callback code below is required for SDK to properly track the activity of your ad
public class MyRewardedListener : RewardedListener
{
public void OnShow(string placementId, ImpressionData impressionData)
{
// Called when a rewarded ad from placementId shows up. In case the ad is a video, audio play will start here.
// On Android, this callback might be called only once the ad is closed.
}
public void OnClick(string placementId)
{
// Called when a rewarded ad from placement 'placementId' is clicked
}
public void OnHide(string placementId)
{
// Called when a rewarded ad from placement 'placementId' hides.
}
public void OnShowFailure(string placementId, ImpressionData impressionData)
{
// Called when an error arises when showing a rewarded ad from placement 'placementId'
}
public void OnAvailable(string placementId)
{
// Called when a rewarded ad from placement 'placementId' becomes available
}
public void OnUnavailable(string placementId)
{
// Called when a rewarded ad from placement 'placementId' becomes unavailable
}
public void OnCompletion(string placementId, bool userRewarded)
{
// Called when a rewarded ad from placement 'placementId' finishes playing. In case the ad is a video, audio play will stop here.
}
public void OnRequestStart(string placementId)
{
// Called when a rewarded ad from placement 'placementId' is going to be requested
}
}
Rewarded.SetRewardedListener(new MyRewardedListener());
Example Showing an Ad
The following example checks to see if a placement is available and if it is, uses the show request to display the ad.
If your game must be paused before showing an ad (e.g., stop audio playback), this is the best moment to do so.
The time between calling this API and the ad actually being shown should be negligible.
This approached is preferable compared to relying on the 'OnShow' callback since on Android, we cannot guarantee it will be called before the ad starts playing.
string placementId = "1234";
if (Rewarded.IsAvailable(placementId)) {
Rewarded.Show(placementId);
}
Server Side Rewarding
For details on configuring Server Side Rewarding, click here.
Important
When using Unity, due to technical limitations on the framework side, we notice that for some very low percentage of users we receive the `OnShowFailure`
followed by the `OnCompletion(true)`
.
We're currently working on fixing the issue. However, in the meantime, if you're using client-side rewarding and you consider the `OnShowFailure`
as a callback to trigger a new request and unblock your game's logic, we recommend you delay this check with the following workaround:
// ...
using System.Collections;
// ...
public class RewardedScene : MonoBehaviour, RewardedListener
{
// ...
private bool CompletionEventReceived;
//...
private void ShowVideo()
{
// ...
this.CompletionEventReceived = false;
Rewarded.Show("your_placement_id");
// ...
}
private void OnShowFailure()
{
this.StartCoroutine( this.WaitUserCompletion());
}
private void OnCompletion(bool userRewarded)
{
this.CompletionEventReceived = true;
if (userRewarded)
{
// credit user
}
else
{
this.UserNotRewarded();
}
}
private IEnumerator WaitUserCompletion()
{
// delay the check for 1 second, giving enough time to receive the OnCompletion callback
yield return new WaitForSeconds(1);
if (!this.CompletionEventReceived) {
this.UserNotRewarded();
}
}
private void UserNotRewarded()
{
// handle your logic for user who didn't complete the rewarded ad
}
}