Tenjin SDK は、TopOn のインプレッションレベルの収益データを取得し、これらのイベントを Tenjin に送信することができます。この連携により、TopOn から配信された各広告インプレッションの収益情報が送信されます。連携の手順は以下の通りです:
- TopOn iOS SDK をインストールします: https://docs.toponad.com/#/en-us/ios/GetStarted/TopOn_Get_Started
AnyThinkiOS iOS SDK の最新バージョン(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のサブスクリプションは機能しなくなります。この場合、topOnImpressionFromJSONメソッドを使用して、デリゲートからTenjinSDKへ広告インプレッションデータを手動で渡す必要があります。 JSONの本文は、以下の形式に従う必要があります:
以下は、TopOnのインプレッション単位の収益データの例です:
| パラメータ | 必須? | 例 |
| adsource_index | いいえ | 0 |
| ad_network_type | いいえ | 文字列 |
| is_header_bidding_adsource | いいえ | Int |
| ecpm_precision | いいえ | 文字列 |
| adsource_id | いいえ | 5656 |
| ecpm | いいえ | 1 |
| シナリオID | いいえ | 文字列 |
| custom_rule | いいえ | 文字列 |
| サブチャンネル | いいえ | testSubChannel |
| 出版社の収益 | はい | 0.001 |
| シナリオ報酬名 | いいえ | 文字列 |
| チャンネル | いいえ | testChannel |
| topon_ad_format | いいえ | 文字列 |
| segment_id | いいえ | 0 |
| 国 | いいえ | DE |
| show_id | いいえ | 文字列 |
| シナリオ報酬数 | いいえ | 0 |
| network_placement_id | いいえ | ca-app-pub-3940256099942544%2F6300978111 |
| topon_placement_id | いいえ | 文字列 |
| ecpm_level | いいえ | 1 |
| reward_user_custom_data | いいえ | 文字列 |
| network_firm_id | いいえ | 2 |
| 通貨 | いいえ | USD |
| 精度 | いいえ | 文字列 |