Callbacks

General callbacks

Loaded Tapdaq Config

Called immediately after the SDK is ready to begin loading adverts.

private void OnEnable () {
	TDCallbacks.TapdaqConfigLoaded += OnTapdaqConfigLoaded;
	TDCallbacks.TapdaqConfigFailedToLoad += OnTapdaqConfigFailToLoad;
}

private void OnDisable () {
	TDCallbacks.TapdaqConfigLoaded -= OnTapdaqConfigLoaded;
	TDCallbacks.TapdaqConfigFailedToLoad -= OnTapdaqConfigFailToLoad;
}

private void OnTapdaqConfigLoaded() {
	// Tapdaq config loaded
}

private void OnTapdaqConfigFailToLoad(TDAdError error) {
	// Tapdaq config has failed to load
}

Advert callbacks

Loaded an advert

Called immediately after an ad is available to the user for a specific placement tag. Note: There is no placement tag for banner.

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

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

private void OnAdAvailable(TDAdEvent e) {
	if (e.adType == "INTERSTITIAL" && e.tag == "main_menu") {
		// Interstitial has loaded
	} else if (e.adType == "VIDEO" && e.tag == "pause") {
		// Video has loaded
	} else if (e.adType == "REWARD_AD" && e.tag == "game_over") {
		// Rewarded video has loaded
	} else if (e.adType == "NATIVE_AD" && e.tag == "ingame") {
		// Native ad has loaded
	} else if (e.adType == "BANNER") {
		// Banner has loaded
	}
}

Failed to load an advert

Called when the ad was not able to be loaded for a specific placement tag. Tapdaq will automatically attempt to load an ad again with a 1 second delay. Note: There is no placement tag for banner.

private void OnEnable() {
	TDCallbacks.AdNotAvailable += OnAdNotAvailable;
}

private void OnDisable() {
	TDCallbacks.AdNotAvailable -= OnAdNotAvailable;
}

private void OnAdNotAvailable(TDAdEvent e) {
	if (e.adType == "INTERSTITIAL" && e.tag == "main_menu") {
		// Interstitial has failed to load
	} else if (e.adType == "VIDEO" && e.tag == "pause") {
		// Video has failed to load
	} else if (e.adType == "REWARD_AD" && e.tag == "game_over") {
		// Rewarded video has failed to load
	} else if (e.adType == "NATIVE_AD" && e.tag == "ingame") {
		// Native ad has failed to load
	} else if (e.adType == "BANNER") {
		// Banner has failed to load
	}
}

About to display an advert

Called immediately before the advert is to be displayed to the user.

private void OnEnable() {
	TDCallbacks.AdWillDisplay += OnAdWillDisplay;
}

private void OnDisable() {
	TDCallbacks.AdWillDisplay -= OnAdWillDisplay;
}

private void OnAdWillDisplay(TDAdEvent e) {
	if (e.adType == "INTERSTITIAL") {
		// Interstitial will display
	} else if (e.adType == "VIDEO") {
		// Video will display
	} else if (e.adType == "REWARD_AD") {
		// Rewarded video will display
	} else if (e.adType == "NATIVE_AD") {
		// Native ad will display
	} else if (e.adType == "BANNER") {
		// Banner will display
	}
}

Displayed an advert

Called immediately after the advert is displayed to the user.

private void OnEnable() {
	TDCallbacks.AdDidDisplay += OnAdDidDisplay;
}

private void OnDisable() {
	TDCallbacks.AdDidDisplay -= OnAdDidDisplay;
}

private void OnAdDidDisplay(TDAdEvent e) {
	if (e.adType == "INTERSTITIAL") {
		// Interstitial did display
	} else if (e.adType == "VIDEO") {
		// Video did display
	} else if (e.adType == "REWARD_AD") {
		// Rewarded video did display
	} else if (e.adType == "NATIVE_AD") {
		// Native ad did display
	} else if (e.adType == "BANNER") {
		// Banner did display
	}
}

Advert closed

Called when the user closes the advert.

private void OnEnable() {
	TDCallbacks.AdClosed += OnAdClosed;
}

private void OnDisable() {
	TDCallbacks.AdClosed -= OnAdClosed;
}

private void OnAdClosed(TDAdEvent e) {
	if (e.adType == "INTERSTITIAL") {
		// Interstitial closed
	} else if (e.adType == "VIDEO") {
		// Video closed
	} else if (e.adType == "REWARD_AD") {
		// Rewarded video closed
	} else if (e.adType == "NATIVE_AD") {
		// Native ad closed
	} else if (e.adType == "BANNER") {
		// Banner closed
	}
}

User clicked an advert

Called when the user clicks the advert.

private void OnEnable() {
	TDCallbacks.AdClicked += OnAdClicked;
}

private void OnDisable() {
	TDCallbacks.AdClicked -= OnAdClicked;
}

private void OnAdClicked(TDAdEvent e) {
	if (e.adType == "INTERSTITIAL") {
		// User did click the interstitial
	} else if (e.adType == "VIDEO") {
		// User did click the video
	} else if (e.adType == "REWARD_AD") {
		// User did click the rewarded video
	} else if (e.adType == "NATIVE_AD") {
		// User did click the native ad
	} else if (e.adType == "BANNER") {
		// User did click the banner
	}
}

Rewarded video callbacks

Received a reward for the user

Called when a reward is ready for the user.

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

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

private void OnRewardVideoValidated(TDVideoReward videoReward) {
	// Reward the user
  	Debug.Log ("The user earned " + videoReward.RewardAmount + " of " + videoReward.RewardName
			+ "   tag=" + videoReward.Tag + " IsRewardValid " + videoReward.RewardValid + " CustomJson: " + videoReward.RewardJson);
}

The debug log would print out The user earned 3 Lives for example.