Advanced

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.

Custom Event Callbacks

For all other events, CustomEvent will be called with a specialised data set for that event.

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

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

private void CustomEvent(Dictionary<string, object> eventData) {
}

Reward Id

The Reward Id is used for server-side callbacks, you can also retrieve it based on placement tags in the SDK like so:

AdManager.GetRewardId (adTag);

Rewarded Video User Id

For server side callbacks, a Hashed User Id can be passed into the ShowRewardVideo method, this will then be added to our server side callback to identify users.

NOTE: The String should be hashed before passed to Tapdaq SDK.

AdManager.ShowRewardVideo ("<PLACEMENT_TAG>", "<HASHED_USER_ID>");

In App Purchase Tracking

Tapdaq & AppLovin can track your users In App Purchases, to pass the data do the following:

string itemName = "";
double itemPrice = 0.0;
string currency = "GBP"; //3 Character currency code
string locale; //Retreive from device e.g. en_GB

#if UNITY_IPHONE
string storeTransactionId; // Retrieve from your IAP plugin
string storeProductId; //Retrieve from your IAP plugin

AdManager.SendIAP_iOS(storeTransactionId, storeProductId, itemName, itemPrice, currency, locale);
#elif UNITY_ANDROID
string IAPData; //Retrieve from your IAP plugin
string IAPSignature; //Retrieve from your IAP plugin
AdManager.SendIAP_Android(IAPData, IAPSignature, itemName, itemPrice, currency, locale);
#endif

AdMob Targeting

As of Tapdaq SDK 7.0.0, an AdMob content rating will be forwarded for every ad request to AdMob, to do this, set the value in the config either before Tapdaq has initialised or after like so:

//After Tapdaq initialises
AdManager.SetAdMobContentRating("MA"); //G PG T MA
AdManager.SetIsAgeRestrictedUser(true); //COPPA/GDPR flag

The tag_for_under_age_of_consent flag will be sent to AdMob if the user is subject to GDPR and AgeRestrictedUser is set. The ChildDirectedTreatment COPPA flag will be sent if user is not known to be subject to GDPR and AgeRestrictedUser is set. Read more about AdMob Targeting here.