Implementing custom AdNetwork
Create class that is inheritance of AdNetwork;
Implement abstact methods;
Every ad sdk should have callbacks for ad start / finish / fail and more. You need to override Init() method with base() call and subscribe to sdk events.
for ShowInterstitial and ShowRewarded make sure to save callback input into _onInterstitialHidden and _onRewardedClosed. It should be like this:
public override void ShowInterstitial(string placement, Action callback = null) {
_onInterstitialHidden = callback; // remember, use on ad adk callbacks
MaxSdk.ShowInterstitial(_appLovinSettings.AdInterstitialId);
}
public override void ShowRewarded(string placement, Action<bool> callback = null) {
_onRewardedClosed = callback; // remember, use on ad adk callbacks
MaxSdk.ShowRewardedAd(_appLovinSettings.AdRewardedId);
}
// this is AppLovin implementation as example.Then invoke cached callbacks from ad sdk callbacks, as example:
private void OnInterstitialHiddenEvent(string adUnitId, MaxSdkBase.AdInfo adInfo) {
_manager.StartInterstitialCooldownAfter(AdType.Interstitial); // this is important to update cooldown for next interstitial
LoadInterstitial();
_onInterstitialHidden?.Invoke();
_onInterstitialHidden = null;
}_manager.StartInterstitialCooldownAfter(AdType.Interstitial or AdType.Rewarded); must be called on success ad watch to update inter show cooldowns. Needs to be after rewarded and inter with correspoding AdType passed to manager.
Add your network implementation script to AdManager and reference it to ActiveNetwork field in AdManager.
You can see ready-made network implementations as examples from Generic Ad Manager page.
Last updated