-
Notifications
You must be signed in to change notification settings - Fork 4
Rewarded Ad object
⚡ Before you start
Make sure you have correctly initialized Mediation Manager via Script or Unity Editor.
Implementation by UnityEditor | Script C#
- Add an RewardedAdObject to the scene
- Load Ad callbacks
- Content callbacks
- Unity Events sample
- Use RewardedAdObject from script
Rewarded ads are ads that users have the option of interacting with in exchange for in-app rewards.
This guide shows you how to integrate rewarded ads into a Unity app.
- Add an GameObject to your scene using
GameObject > Create Empty
in the Unity Editor. - Add Component
CleverAdsSolutions/Rewarded Ad Object
in the inspector to new GameObject. - Select Manager ID from settings asset for each runtime platform.
- Attach function to
OnReward
event to handle reward. - Invoke
Present()
method to show the rewarded video ad.
-
Restart Interstitial Ad interval on rewarded ad closed
The interstitial ad interval will restart after the rewarded ad is closed. -
OnReward
The most important event is called when the user is rewarded for watching a video
Note
An RewardedAdObject 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 rewarded ad has finished loading. -
On Ad Failed To Load
The event is invoked when the rewarded 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 rewarded ad failed to show. The Message parameter describes the type of failure that occurred. -
On Ad Shown
The event is invoked when the rewarded ad is shown. -
On Ad Clicked
The event is invoked when the user clicks on the rewarded 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 rewarded ad is closed.
You can implement functions that correspond to ad callbacks. For example, if you want to handle when a banner ad fails to load:
- Create a function compatible with the ad callback in custom component.
public void OnReward() {
Debug.Log("The user earned the reward.");
}
- 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 rewarded ad instance from the script:
RewardedAdObject rewarded = rewardedObject.GetComponent<RewardedAdObject>();
Before displaying a rewarded ad to users, you must present the user with an explicit choice to view rewarded ad content in exchange for a reward. Rewarded ads must always be an opt-in experience.
Show the rewarded ad:
rewarded.Present();
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🔗