Ad types
The adTypes
parameter in the code is responsible for the ad formats you are going to implement into your app.
Appodeal supports all major mobile ad types:
Interstitial (
Appodeal.INTERSTITIAL
): full-screen ads, that contain a static image or a skippable video.Rewarded video (
Appodeal.REWARDED_VIDEO
): non-skippable video ads that users may choose to watch to get a reward.Non-skippable video (
Appodeal.NON_SKIPPABLE_VIDEO
): video ads that must be watched until the end. This format is an alias ofAppodeal.REWARDED_VIDEO
.Banner (
Appodeal.BANNER
): rectangular ads that occupy a spot within an app's layoutMREC (
Appodeal.MREC
): medium-rectangule ads (300x250px) that appear within in-app content.
- Page not found for multiexcerpt macro.
Interstitial
1. Display interstitial
Appodeal.show(Appodeal.INTERSTITIAL);
2. Check if interstitial is loaded
Appodeal.isLoaded(Appodeal.INTERSTITIAL);
3. Use interstitial callbacks
The callbacks are used to track different events in the lifecycle of an ad, e.g. when an ad was clicked on or closed. To implement them, you need to follow three steps:
3.1 Extend your class with IInterstitialAdListener
:
YourClassName : IInterstitialAdListener;
3.2 Then call the following method:
Appodeal.setInterstitialCallbacks(this);
3.3 Now you can use the following callback methods within your public class
:
#region Interstitial callback handlers public void onInterstitialLoaded(bool isPrecache) { print("Interstitial loaded"); } // Called when interstitial was loaded (precache flag shows if the loaded ad is precache) public void onInterstitialFailedToLoad() { print("Interstitial failed"); } // Called when interstitial failed to load public void onInterstitialShowFailed() { print ("Interstitial show failed"); } // Called when interstitial was loaded, but cannot be shown (internal network errors, placement settings, or incorrect creative) public void onInterstitialShown() { print("Interstitial opened"); } // Called when interstitial is shown public void onInterstitialClosed() { print("Interstitial closed"); } // Called when interstitial is closed public void onInterstitialClicked() { print("Interstitial clicked"); } // Called when interstitial is clicked public void onInterstitialExpired() { print("Interstitial expired"); } // Called when interstitial is expired and can not be shown #endregion
All callbacks are called on native main threads that do not match the main thread of the Unity. If you need to receive callbacks in the main Unity thread follow our Callback Usage Guide.
4. Cache interstitial manually
4.1. To disable automatic caching for interstitials, use the code below before the SDK initialization:
Appodeal.setAutoCache(Appodeal.INTERSTITIAL, false);
4.2. To cache interstitial use:
Appodeal.cache(Appodeal.INTERSTITIAL);
Read more on manual caching in our FAQ.
Rewarded video
1. Display rewarded video
To display rewarded video, call the following code:
Appodeal.show(Appodeal.REWARDED_VIDEO);
2. Check if a rewarded video is loaded
Appodeal.isLoaded(Appodeal.REWARDED_VIDEO);
3. Use rewarded video callbacks
The callbacks are used to track different events in the lifecycle of an ad, e.g. when an ad was clicked on or closed. To implement them, you need to follow three steps:
3.1 Extend your class with IRewardedVideoAdListener
:
YourClassName : IRewardedVideoAdListener;
3.2 Then call the following method:
Appodeal.setRewardedVideoCallbacks(this);
3.3 Now you can use the following callback methods within your public class
:
#region Rewarded Video callback handlers public void onRewardedVideoLoaded(bool isPrecache) { print("Video loaded"); } //Called when rewarded video was loaded (precache flag shows if the loaded ad is precache). public void onRewardedVideoFailedToLoad() { print("Video failed"); } // Called when rewarded video failed to load public void onRewardedVideoShowFailed() { print ("Video show failed"); } // Called when rewarded video was loaded, but cannot be shown (internal network errors, placement settings, or incorrect creative) public void onRewardedVideoShown() { print("Video shown"); } // Called when rewarded video is shown public void onRewardedVideoClicked() { print("Video clicked"); } // Called when reward video is clicked public void onRewardedVideoClosed(bool finished) { print("Video closed"); } // Called when rewarded video is closed public void onRewardedVideoFinished(double amount, string name) { print("Reward: " + amount + " " + name); } // Called when rewarded video is viewed until the end public void onRewardedVideoExpired() { print("Video expired"); } //Called when rewarded video is expired and can not be shown #endregion
All callbacks are called on native main threads that do not match the main thread of the Unity. If you need to receive callbacks in the main Unity thread follow our Callback Usage Guide.
4. Cache rewarded video manually
4.1 To disable automatic caching for rewarded videos use the code below before the SDK initialization:
Appodeal.setAutoCache(Appodeal.REWARDED_VIDEO, false);
4.2 To cache rewarded video use:
Appodeal.cache(this, Appodeal.REWARDED_VIDEO);
5. Advanced
Server-to-server (S2S) rewarded video callbacks
To secure you apps economy we offer S2S reward callbaks. To validate each reward you need to setup callback URL on your server that will receive reward information. We will pass user data to your callback URL that you will need to validate and adjust user balance accordingly.
5.1 Create reward callback URL on your server that will receive reward information.
5.2 Fill created URL and encryption key in the app settings in your dashboard.
5.3 Reward callback will be sent to your URL using GET request with two parameters:
{http://example.com/reward}?data1={data1}&data2={data2}
5.4 Your URL should decrypt the data and validate it.
5.5 Check impression_id
for uniqueness and store it in your system to prevent duplicate transactions.
To set user ID use Appodeal.getUserSettings(this).setUserId("User#123")
method before the SDK initialization.
We offer sample script in Go, PHP, Ruby, Java, Node.js, Python 3 and C# to decrypt the data. If you need samples in other languages please contact our support and we will provide it for you.
Sample in PHP: reward.php.
Sample in Ruby: reward.rb.
Sample in Java: reward.java.
Sample in Node.js: reward.js.
Sample in Python 3: reward.py.
Sample in C#: reward.cs.
Sample in Go: reward.go.
Get reward data for a specific placement
To get reward data and notify your users of it before the video ad is shown, use this method. It returns KeyValuePair with the currency type and amount of the reward.
Appodeal.getRewardParameters(placementName);
Non-skippable video
1. Display non-skippable video
Appodeal.show(Appodeal.NON_SKIPPABLE_VIDEO);
2. Check if a non-skippable video is loaded
Appodeal.isLoaded(Appodeal.NON_SKIPPABLE_VIDEO);
3. Use non-skippable video callbacks
The callbacks are used to track different events in the lifecycle of an ad, e.g. when an ad was clicked on or closed. To implement them, you need to follow three steps:
3.1 Extend your class with INonSkippableVideoAdListener
:
YourClassName : INonSkippableVideoAdListener;
3.2 Then call the following method:
Appodeal.setNonSkippableVideoCallbacks(this);
3.3 Now you can use the following callback methods within your public class
:
#region Non Skippable Video callback handlers public void onNonSkippableVideoLoaded(bool isPrecache) { Debug.Log("NonSkippable Video loaded"); } // Called when non-skippable video is loaded public void onNonSkippableVideoFailedToLoad() { Debug.Log("NonSkippable Video failed to load"); } // Called when non-skippable video failed to load public void onNonSkippableShowFailed() { print ("NonSkippable Video show failed"); } // Called when non-skippable was loaded, but cannot be shown (internal network errors, placement settings, or incorrect creative) public void onNonSkippableVideoShown() { Debug.Log("NonSkippable Video opened"); } // Called when non-skippable video is shown public void onNonSkippableVideoClosed(bool isFinished) { Debug.Log("NonSkippable Video, finished:" + isFinished); } // Called when non-skippable video is closed public void onNonSkippableVideoFinished() { Debug.Log("NonSkippable Video finished"); } // Called when non-skippable video is viewed until the end public void onNonSkippableVideoExpired() { Debug.Log("NonSkippable Video expired"); } Called when non-skippable video is expired and can not be shown #endregion
All callbacks are called on native main threads that do not match the main thread of the Unity. If you need to receive callbacks in the main Unity thread follow our Callback Usage Guide.
4. Cache non-skippable videos manually
4.1 To disable automatic caching for non-skippable videos use the code below before the SDK initialization:
Appodeal.setAutoCache(Appodeal.NON_SKIPPABLE_VIDEO, false);
4.2 To cache non-skippable videos use:
Appodeal.cache(Appodeal.NON_SKIPPABLE_VIDEO);
Banner
1. Display banner at the bottom of the screen
Appodeal.show(Appodeal.BANNER_BOTTOM);
2. Display banner at the top of the screen
Appodeal.show(Appodeal.BANNER_TOP);
3. Display banner at a custom position
Appodeal.BANNER_VIEW
is a banner ad which you can move along the axis to the position you choose. To use it you should first initialize the Appodeal Unity SDK with the Appodeal.BANNER_VIEW
ad format.
To show Appodeal.BANNER_VIEW
use the following code:
Appodeal.showBannerView((int) yPosition, (int) xPosition, (string) placement);
xPosition
use custom int value or constants:Appodeal.BANNER_HORIZONTAL_SMART
— to use the full-screen width;Appodeal.BANNER_HORIZONTAL_CENTER
— to center a banner horizontally;Appodeal.BANNER_HORIZONTAL_RIGHT
— to align a banner to the right;Appodeal.BANNER_HORIZONTAL_LEFT
— to align a banner to the left;
For yPosition
you can use custom int value or constants:
Appodeal.BANNER_TOP
— to align a banner to the top of the screen;Appodeal.BANNER_BOTTOM
— to align a banner to the bottom of the screen.
To set your custom width and height, you can use the constants of The Unity’s Screen.currentResolution.width
and Screen.currentResolution.height
with a constant value.
To hide BANNER_VIEW
use the following code:
Appodeal.hideBannerView();
If your app supports screen rotation, you need to call Appodeal.showBannerView((int) yPosition, (int) xPosition, (string) placement) every time, when screen orientation changes.
4. Check if banner is loaded
Appodeal.isLoaded(Appodeal.BANNER);
5. Use banner callbacks
The callbacks are used to track different events in the lifecycle of an ad, e.g. when an ad was clicked on or closed. To implement them, you need to follow three steps:
5.1 Extend your class with IBannerAdListener
:
YourClassName : IBannerAdListener;
5.2 Then call the following method:
Appodeal.setBannerCallbacks(this);
5.3 Now you can use the following callback methods within your public class:
#region Banner callback handlers public void onBannerLoaded(int height, bool precache) { print("banner loaded"); } // Called when a banner is loaded (height flag shows loaded banner's height, precache flag shows if the loaded ad is precache public void onBannerFailedToLoad() { print("banner failed"); } // Called when banner failed to load public void onBannerShown() { print("banner opened"); } // Called when banner is shown public void onBannerClicked() { print("banner clicked"); } // Called when banner is clicked public void onBannerExpired() { print("banner expired"); } // Called when banner is expired and can not be shown #endregion
All callbacks are called on native main threads that do not match the main thread of the Unity. If you need to receive callbacks in the main Unity thread follow our Callback Usage Guide.
6.Enable Shared View Ads Instance Across Activities Logic (Only for Android platform)
Starting from Android SDK 2.8.1 Appodeal SDK binds the View ads (Banner/MREC) to the Activity which was passed to the Appodeal.show
method.
To make it easier for you to manage View ads display logic across all Activities we added a new method in Appodeal class:
Appodeal.setSharedAdsInstanceAcrossActivities(boolean value); // Default - false
- When this method is used with the
true
parameter, the SDK will show AdView on all new activities without calling additional code from your side. - If you want to control the display yourself, you can call the method with the
false
parameter.
7. Hide banner
Appodeal.hide(Appodeal.BANNER);
8. Destroy shown banner
To free memory from hidden banner call the code below:
Appodeal.destroy(Appodeal.BANNER);
9. Cache banner manually
To disable automatic caching for banners use the code below before the SDK initialization:
Appodeal.setAutoCache(Appodeal.BANNER, false);
Appodeal.cache(this, Appodeal.BANNER);
Read more on manual caching in our FAQ.
10. Configuration
Enable 728x90 banners
To enable 728*90 banner use the following method before initialization:
Appodeal.setTabletBanners(true);
To disable banner refresh animation use the following method before initialization:
Appodeal.setBannerAnimation(false);
Appodeal.setBannerBackground(false);
Smart banners
Smart banners are the banner ads which automatically fit the screen size. Using them helps to deal with the increasing fragmentation of the screen sizes on different devices. In the Appodeal SDK the smart banners are enabled by default. To disable them, use the following method before initialization:
Appodeal.setSmartBanners(false);
MREC
It’s a deprecated ad format and it is recommended to use native ads instead.
1. Show MREC with a custom position
Appodeal.showMrecView((int) yPosition, (int) xPosition, (string) placement);
xPosition
and yPosition
use custom int
value.2. Hide MREC
Appodeal.hideMrecView();
3. Set MREC callbacks
The callbacks are used to track different events in the lifecycle of an ad, e.g. when an ad was clicked on or closed. To implement them, you need to follow three steps:
3.1 Extend your public class
with IMrecAdListener
:
YourClassName : IMrecAdListener;
3.2 Then call the following method:
Appodeal.setMrecCallbacks(this);
3.3 Now you can use the following callback methods within your public class
:
public void onMrecLoaded(bool precache) { print("banner loaded"); } // Called when banner is loaded precache flag shows if the loaded ad is precache) public void onMrecFailedToLoad() { print("banner failed"); } // Called when banner failed to load public void onMrecShown() { print("banner opened"); } // Called when banner is shown public void onMrecClicked() { print("banner clicked"); } // Called when banner is clicked public void onMrecExpired() { print("banner expired"); } // Called when banner is expired and can not be shown #endregion
All callbacks are called on native main threads that do not match the main thread of the Unity. If you need to receive callbacks in the main Unity thread follow our Callback Usage Guide.