-
Notifications
You must be signed in to change notification settings - Fork 4
Return To Play Ad Object
Str4tos edited this page Apr 16, 2024
·
10 revisions
⚡ Before you start
Make sure you have correctly initialized Mediation Manager via Script or Unity Editor.
Implementation by UnityEditor | Script C#
- Add a ReturnToPlayAdObject to the scene
- Load Ad callbacks
- Content callbacks
- Unity Events sample
- Use ReturnToPlayAdObject from script
This guide explains how to integrate interstitial ads into a Unity app.
Important
- The Ad on Return to App is a regular Interstitial Ad.
- Automatic display is only possible when using autoload Interstitial Ad.
- The Ad will be displayed only if the Interstitial Ad is currently loaded. After displaying the Interstitial Ad, it will be necessary to load a new advertisement.
- The Ad will not be shown if the interval since the last closure of the Interstitial Ad has not elapsed.
- Do not activate this ad format if your application displays an AppOpen Ad when returning to the app.
- Add a GameObject to your scene using
GameObject > Create Empty
in the Unity Editor. - Add Component
CleverAdsSolutions/Return To Play Ad Object
in the inspector to new GameObject. - Select Manager ID from the settings asset for each runtime platform.
- Check flag
allowReturnToPlayAd
Note
An ReturnToPlayAdObject does not have any rendered components. Therefore, you can place the GameObject anywhere in the scene.
-
On Ad Loaded
The event is invoked when the ad has finished loading. -
On Ad Failed To Load
The event is invoked when the ad fails to load. The Message parameter describes the type of failure that occurred.
-
On Ad Failed To Show
The event is invoked when the ad failed to show. The Message parameter describes the type of failure that occurred. -
On Ad Shown
The event is invoked when the ad is shown. -
On Ad Clicked
The event is invoked when the user clicks on the ad. -
On Ad Impression
The event is invoked when the ad count impression with Impression Level Data andAdMetaData
. -
On Ad Closed
The event is invoked when the ad is closed.
You can implement functions that correspond to ad callbacks. For example, if you want to handle when the ad fails to shown:
- Create a function compatible with the ad callback in custom component.
public void OnReturnToPlayAdFailedToShow(string reason) {
Debug.Log("ReturnToPlay ad failed to show: " + reason);
}
- Attach the script which contains the above function to any GameObject in the scene.
- Click the + button, then drag & drop the GameObject that you've attached the script to.
- Select the function that you want to link to the ad callback. For the parameterized ad callbacks, select the function to accept the dynamic variable so you can get the parameter value from the SDK.
Get the ReturnToPlay ad instance from the script:
ReturnToPlayAdObject adObject = adObject.GetComponent<ReturnToPlayAdObject>();
Enable ReturnToPlay ad:
adObject.allowReturnToPlayAd = true;
Disable ReturnToPlay ad:
adObject.allowReturnToPlayAd = false;
What’s Next?
- Follow our integration guides and implement our Ad Units:
- Read more about Impression level data.
- Project Setup
- Configuring SDK
- Include Android
- Include iOS
- Additional mediation steps
- App-ads.txt🔗