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 of Appodeal.REWARDED_VIDEO.
  • Banner (Appodeal.BANNER): rectangular ads that occupy a spot within an app's layout
  • MREC (Appodeal.MREC): medium-rectangule ads (300x250px) that appear within in-app content. It’s a deprecated ad format and it is recommended to use native ads instead.

Please note:

Ad types can be combined using "|" operator. For example, Appodeal.INTERSTITIAL | Appodeal.REWARDED_VIDEO.

Appodeal.NON_SKIPPABLE_VIDEO - the alias of Appodeal.REWARDED_VIDEO. Both of them shouldn't be used together.

If you are not sure, which ad formats would suit you the best, check out our FAQ.

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:

1. Extend your class with IInterstitialAdListener:

YourClassName : IInterstitialAdListener;
2. Then call the following method:
Appodeal.setInterstitialCallbacks(this);

#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 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

To disable automatic caching for interstitials, use the code below before the SDK initialization:

Appodeal.setAutoCache(Appodeal.INTERSTITIAL, false);
To cache interstitial use:
Appodeal.cache(Appodeal.INTERSTITIAL);
Read more on manual caching in our FAQ.

Rewarded video

1. Display rewarded video

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:

1. Extend your class with IRewardedVideoAdListener:

YourClassName : IRewardedVideoAdListener;
2. Then call the following method:
Appodeal.setRewardedVideoCallbacks(this);
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 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

To disable automatic caching for rewarded videos use the code below before the SDK initialization:

Appodeal.setAutoCache(Appodeal.REWARDED_VIDEO, false);
To cache rewarded video use:
Appodeal.cache(this, Appodeal.REWARDED_VIDEO);
Read more on manual caching in our FAQ.

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.

1. Create reward callback URL on your server that will receive reward information.

2. Fill created URL and encryption key in the app settings in your dashboard.

3. Reward callback will be sent to your URL using GET request with two parameters:

{http://example.com/reward}?data1={data1}&data2={data2}
4. Your URL should decrypt the data and validate it.

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 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.

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:

1. Extend your class with INonSkippableVideoAdListener:

YourClassName : INonSkippableVideoAdListener;
2. Then call the following method:
Appodeal.setNonSkippableVideoCallbacks(this);
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 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

To disable automatic caching for non-skippable videos use the code below before the SDK initialization:

Appodeal.setAutoCache(Appodeal.NON_SKIPPABLE_VIDEO, false);
To cache non-skippable videos use:
Appodeal.cache(Appodeal.NON_SKIPPABLE_VIDEO);
Read more on manual caching in our FAQ.

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);
For xPosition and yPosition 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 Appodeal.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:

1. Extend your class with IBannerAdListener:

YourClassName : IBannerAdListener;
2. Then call the following method:
Appodeal.setBannerCallbacks(this);
3. Now you can use the following callback methods within your public class:
#region Banner callback handlers
public void onBannerLoaded(bool precache) { print("banner loaded"); } // Called when banner is loaded (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. Handle orientation change

The screen rotation always recreates the Unity activity, which may cause a banner disappearing. To prevent that, add the following code within the OnApplicationFocus() method of your MonoBehaviour:

void OnApplicationFocus(bool hasFocus) {
 if(hasFocus) {
    Appodeal.onResume(Appodeal.BANNER_TOP);
  }
}

In order for the previously shown banner to be shown after the activity exits from the "Paused" state, you must override the "OnApplicationFocus" method of your MonoBehaviour and call the onResume method on Appodeal indicating the type of banner previously shown.


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);
To cache banners use:
Appodeal.cache(this, Appodeal.BANNER);

10. Configuration

Enable 728x90 banners

To enable 728*90 banner use the following method before initialization:

Appodeal.setTabletBanners(true);

Disable banner refresh animation

To disable banner refresh animation use the following method before initialization:

Appodeal.setBannerAnimation(false);

Disable banner background (iOS Only)

To disable smart banners use the following method before initialization:


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);
For xPosition and yPosition use custom int value.

2. Hide MREC

Appodeal.showMrecView((int) yPosition, (int) xPosition, (string) placement);

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:

1. Extend your public class with IMrecAdListener:

YourClassName : IMrecAdListener;
2. Then call the following method:
Appodeal.setMrecCallbacks(this);
3. Now you can use the following callback methods within your public class:
#region Banner callback handlers
public void onBannerLoaded(bool precache) { print("banner loaded"); } // Called when banner is loaded 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.