The Tenjin SDK can listen to TopOn impression level revenue data and send these events to Tenjin. This integration sends revenue information for each ad impression served from TopOn. Here are the steps to integrate:
- Install 安装 the TopOn iOS SDK: https://docs.toponad.com/#/en-us/ios/GetStarted/TopOn_Get_Started
NOTE: Please ensure you have the latest AnyThinkiOS iOS SDK installed (> 5.7.99)
- After receiving the Ad extra dictionary, pass it to the Tenjin SDK:
[TenjinSDK initialize:@"<SDK_KEY>"];
[TenjinSDK connect];
[[ATAdManager sharedManager] loadADWithPlacementID:@"<INTERSTITIAL_AD_ID>" extra:@{} delegate:self];
-(void) didShowNativeBannerAdInView:(ATNativeBannerView*)bannerView placementID:(NSString*)placementID extra:(NSDictionary *)extra{
[TenjinSDK topOnImpressionFromDict:extra];
}
Below is an example of TopOn Banner integration and subscribing to impression events.
@implementation TJNTopOnViewController
- (void)viewDidLoad {
[super viewDidLoad];
_bannerPlacementID = @"<BANNER_AD_ID>";
_interstitialPlacementID = @"<INTERSTITIAL_AD_ID>";
[[ATAdManager sharedManager] loadADWithPlacementID:_interstitialPlacementID extra:@{} delegate:self];
if ([ATNativeBannerWrapper nativeBannerAdReadyForPlacementID:_bannerPlacementID]) {
[self showAd];
} else {
[ATNativeBannerWrapper loadNativeBannerAdWithPlacementID:_bannerPlacementID extra:@{kATExtraInfoNativeAdSizeKey:[NSValue valueWithCGSize:CGSizeMake(CGRectGetWidth(self.view.bounds), 120.0f)]} customData:nil delegate:self];
}
}
-(void) showAd {
ATNativeBannerView *bannerView = [ATNativeBannerWrapper retrieveNativeBannerAdViewWithPlacementID:_bannerPlacementID extra:@{kATNativeBannerAdShowingExtraAdSizeKey:[NSValue valueWithCGSize:CGSizeMake(CGRectGetWidth([UIScreen mainScreen].bounds), 120.0f)], kATNativeBannerAdShowingExtraAutorefreshIntervalKey:@10.0f, kATNativeBannerAdShowingExtraHideCloseButtonFlagKey:@NO, kATNativeBannerAdShowingExtraCTAButtonBackgroundColorKey:[UIColor redColor], kATNativeBannerAdShowingExtraCTAButtonTitleColorKey:[UIColor whiteColor], kATNativeBannerAdShowingExtraCTAButtonTitleFontKey:[UIFont systemFontOfSize:12.0f], kATNativeBannerAdShowingExtraTitleColorKey:[UIColor grayColor], kATNativeBannerAdShowingExtraTitleFontKey:[UIFont systemFontOfSize:12.0f], kATNativeBannerAdShowingExtraTextColorKey:[UIColor lightGrayColor], kATNativeBannerAdShowingExtraTextFontKey:[UIFont systemFontOfSize:10.0f], kATNativeBannerAdShowingExtraBackgroundColorKey:[UIColor whiteColor], kATNativeBannerAdShowingExtraAdvertiserTextFontKey:[UIFont systemFontOfSize:12.0f], kATNativeBannerAdShowingExtraAdvertiserTextColorKey:[UIColor lightGrayColor]} delegate:self];
bannerView.frame = CGRectMake(.0f, 100.0f, CGRectGetWidth(bannerView.bounds), CGRectGetHeight(bannerView.bounds));
bannerView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[self.view addSubview:bannerView];
}
- (IBAction)showInterstitialAd {
[[ATAdManager sharedManager] showInterstitialWithPlacementID:_interstitialPlacementID inViewController:self delegate:self];
}
#pragma mark - native banner delegate(s)
-(void) didFinishLoadingNativeBannerAdWithPlacementID:(NSString *)placementID {
NSLog(@"TJNTopOnViewController::didFinishLoadingNativeBannerAdWithPlacementID:%@", placementID);
[self showAd];
}
-(void) didFailToLoadNativeBannerAdWithPlacementID:(NSString*)placementID error:(NSError*)error {
NSLog(@"TJNTopOnViewController::didFailToLoadNativeBannerAdWithPlacementID:%@ error:%@", placementID, error);
}
-(void) didShowNativeBannerAdInView:(ATNativeBannerView*)bannerView placementID:(NSString*)placementID extra:(NSDictionary *)extra{
NSLog(@"TJNTopOnViewController::didShowNativeBannerAdInView:%@ placementID:%@ with extra: %@",bannerView, placementID,extra);
[TenjinSDK topOnImpressionFromDict:extra];
}
-(void) didClickNativeBannerAdInView:(ATNativeBannerView*)bannerView placementID:(NSString*)placementID extra:(NSDictionary *)extra{
NSLog(@"TJNTopOnViewController::didClickNativeBannerAdInView:%@ placementID:%@ with extra: %@",bannerView, placementID,extra);
}
-(void) didClickCloseButtonInNativeBannerAdView:(ATNativeBannerView*)bannerView placementID:(NSString*)placementID extra:(NSDictionary *)extra{
NSLog(@"TJNTopOnViewController::didClickCloseButtonInNativeBannerAdView:%@ placementID:%@", bannerView, placementID);
}
-(void) didAutorefreshNativeBannerAdInView:(ATNativeBannerView*)bannerView placementID:(NSString*)placementID extra:(NSDictionary *)extra{
NSLog(@"TJNTopOnViewController::didAutorefreshNativeBannerAdInView:%@ placementID:%@ with extra: %@",bannerView, placementID,extra);
}
-(void) didFailToAutorefreshNativeBannerAdInView:(ATNativeBannerView*)bannerView placementID:(NSString*)placementID extra:(NSDictionary *)extra error:(NSError*)error {
NSLog(@"TJNTopOnViewController::didFailToAutorefreshNativeBannerAdInView:%@ placementID:%@ error:%@", bannerView, placementID, error);
}
- (void)didNativeBannerDeeplinkOrJumpInView:(ATNativeBannerView *)bannerView placementID:(NSString *)placementID extra:(NSDictionary *)extra result:(BOOL)success {
NSLog(@"TJNTopOnViewController::didNativeBannerDeeplinkOrJumpInView:%@ extra:%@", placementID, extra);
}
- (void)didFinishLoadingSplashADWithPlacementID:(NSString *)placementID isTimeout:(BOOL)isTimeout {
NSLog(@"TJNTopOnViewController::didFinishLoadingSplashADWithPlacementID:%@", placementID);
}
- (void)didTimeoutLoadingSplashADWithPlacementID:(NSString *)placementID {
NSLog(@"TJNTopOnViewController::didTimeoutLoadingSplashADWithPlacementID:%@", placementID);
}
#pragma mark - Interstitial delegate method(s)
-(void) didFinishLoadingADWithPlacementID:(NSString *)placementID {
NSLog(@"TJNTopOnViewController::didFinishLoadingADWithPlacementID:%@", placementID);
}
-(void) didFailToLoadADWithPlacementID:(NSString*)placementID error:(NSError*)error {
NSLog(@"TJNTopOnViewController::didFailToLoadADWithPlacementID:%@ error:%@", placementID, error);
}
-(void) interstitialDidShowForPlacementID:(NSString *)placementID extra:(NSDictionary *)extra {
NSLog(@"TJNTopOnViewController::interstitialDidShowForPlacementID:%@ extra:%@", placementID, extra);
[TenjinSDK topOnImpressionFromDict:extra];
}
-(void) interstitialFailedToShowForPlacementID:(NSString*)placementID error:(NSError*)error extra:(NSDictionary *)extra {
NSLog(@"TJNTopOnViewController::interstitialFailedToShowForPlacementID:%@ error:%@ extra:%@", placementID, error, extra);
}
-(void) interstitialDidFailToPlayVideoForPlacementID:(NSString*)placementID error:(NSError*)error extra:(NSDictionary*)extra {
NSLog(@"TJNTopOnViewController::interstitialDidFailToPlayVideoForPlacementID:%@ error:%@ extra:%@", placementID, error, extra);
}
-(void) interstitialDidStartPlayingVideoForPlacementID:(NSString*)placementID extra:(NSDictionary *)extra {
NSLog(@"TJNTopOnViewController::interstitialDidStartPlayingVideoForPlacementID:%@ extra:%@", placementID, extra);
}
-(void) interstitialDidEndPlayingVideoForPlacementID:(NSString*)placementID extra:(NSDictionary *)extra {
NSLog(@"TJNTopOnViewController::interstitialDidEndPlayingVideoForPlacementID:%@ extra:%@", placementID, extra);
}
-(void) interstitialDidCloseForPlacementID:(NSString*)placementID extra:(NSDictionary *)extra {
NSLog(@"TJNTopOnViewController::interstitialDidCloseForPlacementID:%@ extra:%@", placementID, extra);
}
-(void) interstitialDidClickForPlacementID:(NSString*)placementID extra:(NSDictionary *)extra {
NSLog(@"TJNTopOnViewController::interstitialDidClickForPlacementID:%@ extra:%@", placementID, extra);
}
- (void)interstitialDeepLinkOrJumpForPlacementID:(NSString *)placementID extra:(NSDictionary *)extra result:(BOOL)success {
NSLog(@"TJNTopOnViewController::interstitialDeepLinkOrJumpForPlacementID:%@ extra:%@", placementID, extra);
}
@end
- [IMPORTANT] If you have other services (such as Game Analytics) already fetching TopOn Impressions delegate, the Tenjin subscription will no longer work. In this case, you must manually pass the ad impression data from the delegate to TenjinSDK using the topOnImpressionFromJSON method. The JSON body should follow this format:
Below is an example of impression level revenue data from TopOn:
| Parameter | Required? | Example |
| adsource_index | 没有 | 0 |
| ad_network_type | 没有 | String |
| is_header_bidding_adsource | 没有 | Int |
| ecpm_precision | 没有 | String |
| adsource_id | 没有 | 5656 |
| 什么是移动营销里的eCPM,以及如何计算? | 没有 | 1 |
| scenario_id | 没有 | String |
| custom_rule | 没有 | String |
| sub_channel | 没有 | testSubChannel |
| publisher_revenue | 是 | 0.001 |
| scenario_reward_name | 没有 | String |
| channel | 没有 | testChannel |
| topon_ad_format | 没有 | String |
| segment_id | 没有 | 0 |
| country | 没有 | DE |
| show_id | 没有 | String |
| scenario_reward_number | 没有 | 0 |
| network_placement_id | 没有 | ca-app-pub-3940256099942544%2F6300978111 |
| topon_placement_id | 没有 | String |
| ecpm_level | 没有 | 1 |
| reward_user_custom_data | 没有 | String |
| network_firm_id | 没有 | 2 |
| currency | 没有 | USD |
| precision | 没有 | String |