SDK Tenjin может отслеживать данные о доходах на уровне показов от TopOn и отправлять эти события в Tenjin. Эта интеграция обеспечивает передачу информации о доходах по каждому рекламному показу, размещенному через TopOn. Ниже приведены шаги по интеграции:
- Установите SDK TopOn iOS: https://docs.toponad.com/#/en-us/ios/GetStarted/TopOn_Get_Started
Убедитесь, что у вас установлена последняя версия SDK AnyThinkiOS iOS (> 5.7.99). - После получения словаря Ad extra передайте его в Tenjin SDK:
Objective-C
[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];
}Ниже приведен пример интеграции TopOn Banner и подписки на события просмотра.
Objective-C
@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- [ВАЖНО] Если у вас есть другие сервисы (например, Game Analytics), которые уже получают данные делегата TopOn Impressions, подписка на Tenjin перестанет работать. В этом случае вам необходимо вручную передать данные о показах рекламы из делегата в TenjinSDK с помощью метода topOnImpressionFromJSON. Тело JSON должно соответствовать следующему формату:
Ниже приведён пример данных о выручке на уровне показов из TopOn:
| Параметр | Обязательно? | Пример |
| adsource_index | Нет | 0 |
| ad_network_type | Нет | Строка |
| is_header_bidding_adsource | Нет | Int |
| ecpm_precision | Нет | Строка |
| adsource_id | Нет | 5656 |
| ecpm | Нет | 1 |
| scenario_id | Нет | Строка |
| пользовательское_правило | Нет | Строка |
| sub_channel | Нет | testSubChannel |
| доход_издателя | Да | 0.001 |
| название_награды_за_сценарий | Нет | Строка |
| канал | Нет | testChannel |
| topon_ad_format | Нет | Строка |
| segment_id | Нет | 0 |
| страна | Нет | DE |
| show_id | Нет | Строка |
| номер_награды_в_сценарии | Нет | 0 |
| идентификатор_размещения_в_сети | Нет | ca-app-pub-3940256099942544%2F6300978111 |
| topon_placement_id | Нет | Строка |
| ecpm_level | Нет | 1 |
| reward_user_custom_data | Нет | Строка |
| идентификатор_сетевой_компании | Нет | 2 |
| валюта | Нет | долл. США |
| точность | Нет | Строка |