There is a guide here on how to develop custom events.
If you're using AdMob SDK Mediation with ad unit /9999/company.app/channel
, then this ad unit should be an SDK Mediation creative
within DFP. One of your networks should be a Custom Event
with the following settings:
Parameter: 9A9A9AA99999999A999AA9A99AA99AAAA999A9AA (or whatever your YOC tag is)
Label: YOC Group (This is just a label so you remember what this custom event is for)
Class Name: AppDelegate (You should really implement the custom event in it's own
class, and replace the class name with that class)
Then when implementing the custom event, you can reference serverParameter
as the YOCTag like you already have.
You don't want to implement GADCustomEventBannerDelegate
yourself. By your class implementing GADCustomEventBanner
, and adding:
@synthesize delegate
at the top of your implementation, you have access to an instance of this object via:
self.delegate
You'll want to use that delegate to tell the custom event (and thereby AdMob Mediation) that YOC returned or failed to return an ad. Based on the YOC delegate, your mapping might look something like this:
- (UIViewController *)viewControllerForPresentingYOCAdView {
NSLog(@" viewControllerForPresentingYOCAdView ");
return self.root;
}
- (void)yocAdViewDidInitialize:(YOCAdView *)yocAdView {
NSLog(@" yocAdViewDidInitialize ");
// Assuming this means the yocAdView was received.
[self.delegate customEventBanner:self didReceiveAd:yocAdView];
}
- (void)yocAdView:(YOCAdView *)yocAdView didFailWithError:(NSError *)error {
NSLog(@" didFailWithError: %@ ", error);
[self.delegate customEventBanner:self didFailAd:error];
}
- (void)yocAdViewDidHide:(YOCAdView *)yocAdView {
NSLog(@" yocAdViewDidHide ");
}
- (void)yocAdViewDidReload:(YOCAdView *)yocAdView {
NSLog(@" yocAdViewDidReload ");
[self.delegate customEventBanner:self didReceiveAd:yocAdView];
}
- (void)yocAdViewWillPresentModalViewController:(YOCAdView *)yocAdView {
NSLog(@" yocAdViewWillPresentModalViewController ");
[self.delegate customEventBanner:self clickDidOccurInAd:yocAdView];
[self.delegate customEventBannerWillPresentModal:self];
[self.delegate customEventBannerWillLeaveApplication:self];
}
- (void)yocAdViewWillDismissModalViewController:(YOCAdView *)yocAdView {
NSLog(@" yocAdViewWillDismissModalViewController ");
[self.delegate customEventBannerWillDismissModal:self];
}
Finally, you don't want to invoke GADCustomEventBannerDelegate
methods in your GADBannerViewDelegate
callback methods. These are invoked by AdMob telling you that mediation came back with an ad. The GADBannerViewDelegate
implementation is part of your main app, and should stay out of your custom event class's implementation.
I know the guide invokes the custom event delegate methods in its GADBannerViewDelegate
implementation. The difference is the guide is writing a custom event to implement AdMob, so in the context of the guide, the GADBannerViewDelegate
is behaving like the YOCAdViewDelegate
in your example.