5 - Request and load an ad

Before you want to display an ad, you have to request our server and when you got a success response download the ad. There are several ways to do this.

Automatic request (and loading) - easiest way to use Palmup

If you want to display ad in only one location in your app, you can just activate automatic loading by checking this box in the palmup menu.

An ad will always be loaded in your app and ready to be displayed.

If no ad is available from our ad-Network, then you can use the function RequestAd() few minutes later to try to fetch a new ad.

Manual request (and loading)

If you want to force the loading of an ad manually you can use the RequestAd() method.

Palmup.launcher.RequestAd()

An ad will be requested to our server and then downloaded automatically until the ad is "ready to display"

This can be useful when an ad has not been loaded at the start of your app due to network issues.

Custom adUnit request & automatic download

The Request_Ad() method got enriched with arguments that allows you to request a specific adUnit

If you want to request ads from several adUnits you can use the method below :

Palmup.launcher.Request_Ad(string AdUnit)

This can be useful if you want to display several ads in your app at different locations

As the requests are responded successfully, the ads are automatically downloaded on the phone.

Waterfall Request

If you want to request ads from several adUnits and be able to manually choose which request to download then you can use the method below :

Request_Ad(string AdUnit, bool autoDownloadWhenSuccess) with autoDownloadWhenSuccess = false

Palmup.launcher.Request_Ad(string AdUnit, false)

Be careful to get in touch with us in order to setup your adUnit names on Palmup server side

Example

You have set with us 3 adUnit for 3 different prices named "waterfall_Rank1", "waterfall_Rank2" and"waterfall_Rank3".

You can request each of theses ads using the following method Request_Ad(string adUnit)

//Call 3 adUnits at the same time and wait for the response
Palmup.launcher.Request_Ad("waterfall_Rank1",false)
Palmup.launcher.Request_Ad("waterfall_Rank2",false)
Palmup.launcher.Request_Ad("waterfall_Rank3",false)

Then be aware of our server response, using the <string> callback OnAdDemandSuccessAdUnit<string>. This callback will fire with a ad success response and give you the name of the targeted adUnit.

using Palmup;
void Start(){
// suscribe to the Palmup OnAdDemandSuccessAdUnit callback
PalmupLauncher.OnAdDemandSuccessAdUnit += OnAdDemandSuccessAdUnit
}
void OnAdDemandSuccessAdUnit(string adUnit) {
// Get this function fired when ad adUnit request is successful
Debug.Log("adUnit request success :" + adUnit);
}
//For example in your console log you will get :
- "adUnit request success : waterfall_Rank2"
- "adUnit request success : waterfall_Rank3"
//Which mean only "waterfall_Rank2" & "waterfall_Rank3" have been successful

Finally, when you got a response (or several) from our server, choose which Ad you want to download using the DownloadAd(string adUnit) method.

// Choose to download a specific adUnit ad when the request has been successful
Palmup.Launcher.DownloadAd("waterfall_Rank2")

Once the ad is downloaded you can display it using the Display_Ad(string adUnit)

Palmup.launcher.Display_Ad("waterfall_Rank2")

After the ad has been displayed and before requesting a new batch of ads, we encourage you to clean the adRequest that have been not downloaded using the killAllAds(bool reloadAutomatically) Method with reloadAutomatically = false;

Palmup.launcher.killAllAds(false)

You are ready to go with your waterfall