Rewarded Video

Rewarded video ads are full-screen videos that appear inside your application.

1. Load the rewarded video

Make sure you add the Tapdaq namespace to the top of your script:

using Tapdaq;

Before displaying a rewarded video to the user, please load the rewarded ad as shown below:

AdManager.LoadRewardedVideo("game_over");

2. Display the rewarded video

Next, you need to display the rewarded ad to the user when they tap a button. Let's say you linked a TappedReward() method to a button.

public void TappedReward() {
	if (AdManager.IsRewardedVideoReady("game_over")) {
		AdManager.ShowRewardVideo("game_over");
	}
}

This code checks to ensure there is a rewarded video ready to display before displaying it.

If you want to check a rewarded video is loaded before displaying the button a user would tap to see the reward, implement the following:

private void OnEnable() {
	TDCallbacks.AdAvailable += OnAdAvailable;
}

private void OnDisable() {
	TDCallbacks.AdAvailable -= OnAdAvailable;
}

private void OnAdAvailable(TDAdEvent e) {
    if (e.adType == "REWARD_AD" && e.tag == "game_over") {
    	// Add code here to display or enable your Rewarded Video button.
    }
}

This ensures that the button is only displayed after a rewarded video has been successfully loaded and is ready to play. For a full list of rewarded video delegate methods we support, see our Advanced page.

Note: We strongly advise against trying to show a rewarded video ad on application launch.*

3. Reward the user

Once the user has watched a video, the player should be rewarded. Use the RewardVideoValidated listener to obtain the reward.

private void OnEnable() {
	TDCallbacks.RewardVideoValidated += OnRewardVideoValidated;
}

private void OnDisable() {
	TDCallbacks.RewardVideoValidated -= OnRewardVideoValidated;
}

private void OnRewardVideoValidated(TDVideoReward videoReward) {
	Debug.Log ("I got " + videoReward.RewardAmount + " of " + videoReward.RewardName 
			+ "   tag=" + videoReward.Tag + " IsRewardValid " + videoReward.RewardValid + " CustomJson: " + videoReward.RewardJson);
			
	if(videoReward.RewardValid) {
		//Give Reward
	} else {
		//Reward is invalid, video may not have completed or an ad network may have refused to the provide reward
	}
}

Note: TDVideoReward.eventId is a unique identifier for every reward given to a user.

Export your application to iOS and Android, then run your application to test the ad displays correctly.

4. Load another rewarded video on close

If you wish to load another rewarded video after you have shown one, implement one of the following options:

A. Auto Reload all Ads

To auto reload all ads using the same placment tag set the Auto Reload option in Tapdaq Settings, like so: Interstitial - Auto Reload

B. Implement Delegate Event

Add a delegate event for OnAdClosed, then call load within the delegate method like so:

// Subscribe to Tapdaq events
private void OnEnable () {
	TDCallbacks.AdClosed += OnAdClosed;
}

// Unsubscribe from Tapdaq events
private void OnDisable () {
	TDCallbacks.AdClosed -= OnAdClosed;
}

private void OnAdClosed(TDAdEvent e) {
	if (e.IsRewardedVideoEvent ()) {
		AdManager.LoadRewardedVideo (e.tag);
	}
}

Server Side Callbacks

Tapdaq SDK triggers server-side callbacks when a reward is provided, along with the client side didVerify callback.

Optionally you can add a Hashed User Id to the callback to identify the user to reward.

Need help?

If you are having any problems integrating, feel free to contact us on [email protected] and we will be more than happy to help.

What's next?

Now that you have successfully integrated a rewarded video into your app, what would you like to do next?