我正在使用Google AdMobs DFP來提供來自其他網絡的中介橫幅。我添加了Millennial和InMobi,但現在我需要添加一個沒有DFP適配器的網絡(YOC組),因此我需要實施「自定義事件」。我已閱讀有關使用自定義事件實施不受支持的中介網絡的指南和技術文檔,但仍無法理解它是如何連接兩個SDK(Google AdMobs SDK和中介網絡的SDK)的。Google AdMobs自定義點擊事件不適用於不受支持的網絡
如果我將yoc ad id(格式爲'9A9A9AA99999999A999AA9A99AA99AAAA999A9AA')硬編碼爲示例廣告併發送請求,那麼沒有適配器(YOC)的網絡可以正常工作。橫幅迴歸正常,並使用YOC SDK顯示交互式/富媒體廣告。
但是在我的應用程序中,我只有一個Google DFP帳戶ID(格式爲「/9999/company.app/channel」),我發送了使用Google AdMobs SDK(v。6.2.1)的請求以DFP。該請求然後返回具有特定中介廣告網絡的響應以嘗試並從中請求橫幅廣告。我目前的設置是YOC在DFP中投放100%的廣告。
問題:我得到從YOC廣告網絡返回的橫幅廣告,並在屏幕上顯示。它會註冊頁面展示次數(使用DFP廣告管理系統),但它不會像觸摸/按下事件那樣對我的廣告視圖的初始化參數進行硬編碼。然而,我不能對yoc廣告ID進行硬編碼(初始化時),因爲它只適用於一個橫幅廣告,並且我需要針對每個頻道中的每個特定廣告使用不同的橫幅廣告。
下面是我試圖在方法中使用NSLogs來實現登錄到控制檯並顯示正在調用方法的示例代碼。這是一個非常基本的應用程序,並將所有代碼放在一個地方以便於閱讀。
AppDelegate.h
#import < UIKit/UIKit.h>
#import "GADBannerView.h"
#import "GADBannerViewDelegate.h"
#import "GADCustomEventBanner.h"
#import "GADCustomEventBannerDelegate.h"
#import < YOCAdSDK/YOCAdView.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate, GADBannerViewDelegate, GADCustomEventBanner, GADCustomEventBannerDelegate, YOCAdViewDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) UIViewController *root;
@end
AppDelegate.m
#import "AppDelegate.h"
#import "GADBannerView.h"
#import <YOCAdSDK/YOCAdSize.h>
@implementation AppDelegate
@synthesize root;
@synthesize delegate; // GADCustomEventBannerDelegate set on GADCustomEventBanner
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
CGRect bounds = [[UIScreen mainScreen] bounds];
self.window = [[UIWindow alloc] initWithFrame:bounds];
self.window.backgroundColor = [UIColor greenColor];
GADBannerView *banner = [[GADBannerView alloc] initWithAdSize:kGADAdSizeLeaderboard origin:CGPointMake(0, 0)];
self.root = [[UIViewController alloc] initWithNibName:nil bundle:nil];
UIView *base = [[UIView alloc] initWithFrame:bounds];
base.backgroundColor = [UIColor greenColor];
self.root.view = base;
// the adUnitID is always of our DFP account number of the format '/9999/company.app/aa_aa<channelName>_<channelName>app'
banner.adUnitID = @"/9999/company.app/aa_aadebate_debateapp";
banner.delegate = self;
banner.rootViewController = self.root;
self.delegate = self;
[base addSubview:banner];
[base bringSubviewToFront:banner];
[banner loadRequest:[GADRequest request]];
[self.window setRootViewController:self.root];
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
[self.window makeKeyAndVisible];
return YES;
}
#pragma mark GADBannerViewDelegate
- (void)adViewDidReceiveAd:(GADBannerView *)view {
NSLog(@" adViewDidReceiveAd ");
NSLog(@" view: %@ ", [view description]);
// for other ad networks here we get view.mediatedAdView = IMAdView (InMobi) or view.mediatedAdView = MMAdView (Millennial) but with YOC view.mediatedAdView = nil;
[self.delegate customEventBanner:self didReceiveAd:view];
}
- (void)adView:(GADBannerView *)view didFailToReceiveAdWithError:(GADRequestError *)error {
NSLog(@" didFailToReceiveAdWithError ");
[self.delegate customEventBanner:self didFailAd:error];
}
- (void)adViewWillPresentScreen:(GADBannerView *)adView {
NSLog(@" adViewWillPresentScreen ");
[self.delegate customEventBanner:self clickDidOccurInAd:adView];
[self.delegate customEventBannerWillPresentModal:self];
}
- (void)adViewWillDismissScreen:(GADBannerView *)adView {
NSLog(@" adViewWillDismissScreen ");
[self.delegate customEventBannerWillDismissModal:self];
}
- (void)adViewDidDismissScreen:(GADBannerView *)adView {
NSLog(@" adViewDidDismissScreen ");
[self.delegate customEventBannerDidDismissModal:self];
}
- (void)adViewWillLeaveApplication:(GADBannerView *)adView {
NSLog(@" adViewWillLeaveApplication ");
[self.delegate customEventBannerWillLeaveApplication:self];
}
#pragma mark GADCustomEventBanner
- (void)requestBannerAd:(GADAdSize)adSize
parameter:(NSString *)serverParameter
label:(NSString *)serverLabel
request:(GADCustomEventRequest *)request {
NSLog(@" requestBannerAd ");
// not sure if we initialiase the YOC tag here or how we would do this if can't hard code the yocTag to the format '9A9A9AA99999999A999AA9A99AA99AAAA999A9AA'
// and we only have the banner view returned from DFP with the id '/9999/company.app/aa_aadebate_debateapp'
YOCAdView *yocAdView = [[YOCAdView alloc] initWithYOCTag:serverParameter delegate:self size:kLeaderboard728x90 position:CGPointMake(0, 0)];
yocAdView.delegate = self;
[yocAdView load];
[self.root.view addSubview:yocAdView];
}
#pragma mark GADCustomEventBannerDelegate
- (void)customEventBanner:(id<GADCustomEventBanner>)customEvent didReceiveAd:(UIView *)view {
NSLog(@" [(GADBannerView *)view adUnitID]: %@ ", [(GADBannerView *)view adUnitID]);
NSLog(@" [(GADBannerView *)view delegate]: %@ ", [(GADBannerView *)view delegate]);
NSLog(@" [(id<YOCAdViewDelegate>)[customEvent delegate] viewControllerForPresentingYOCAdView]: %@ ", [(id<YOCAdViewDelegate>)[customEvent delegate] viewControllerForPresentingYOCAdView]);
// not sure if we initialiase the YOC tag here or how we would do this if can't hard code the yocTag to '9A9A9AA99999999A999AA9A99AA99AAAA999A9AA"
// and we only have the banner view returned from DFP with the id '/9999/company.app/aa_aadebate_debateapp'
[customEvent requestBannerAd:kGADAdSizeLeaderboard parameter:@"???" label:nil request:nil];
// the key might be that the [customEvent delegate] is of type YOCAdViewDelegate and we can do code specific to YOC here...
// but again not sure how to initialize the YOCAdView because we already have the banner view returned from DFP (with a different format account id)
// [(id<YOCAdViewDelegate>)[customEvent delegate] yocAdViewDidInitialize:yocAdView];
}
- (void)customEventBanner:(id<GADCustomEventBanner>)customEvent didFailAd:(NSError *)error {
NSLog(@" customEventBanner:didFailAd ");
}
- (void)customEventBanner:(id<GADCustomEventBanner>)customEvent clickDidOccurInAd:(UIView *)view {
NSLog(@" customEventBanner:clickDidOccurInAd ");
}
- (void)customEventBannerWillPresentModal:(id<GADCustomEventBanner>)customEvent {
NSLog(@" customEventBannerWillPresentModal ");
}
- (void)customEventBannerWillDismissModal:(id<GADCustomEventBanner>)customEvent {
NSLog(@" customEventBannerWillDismissModal ");
}
- (void)customEventBannerDidDismissModal:(id<GADCustomEventBanner>)customEvent {
NSLog(@" customEventBannerDidDismissModal ");
}
- (void)customEventBannerWillLeaveApplication:(id<GADCustomEventBanner>)customEvent {
NSLog(@" customEventBannerWillLeaveApplication ");
}
#pragma mark YOCAdViewDelegate
- (UIViewController *)viewControllerForPresentingYOCAdView {
NSLog(@" viewControllerForPresentingYOCAdView ");
return self.root;
}
- (void)yocAdViewDidInitialize:(YOCAdView *)yocAdView {
NSLog(@" yocAdViewDidInitialize ");
}
- (void)yocAdView:(YOCAdView *)yocAdView didFailWithError:(NSError *)error {
NSLog(@" didFailWithError: %@ ", error);
}
- (void)yocAdViewDidHide:(YOCAdView *)yocAdView {
NSLog(@" yocAdViewDidHide ");
}
- (void)yocAdViewDidReload:(YOCAdView *)yocAdView {
NSLog(@" yocAdViewDidReload ");
}
- (void)yocAdViewWillPresentModalViewController:(YOCAdView *)yocAdView {
NSLog(@" yocAdViewWillPresentModalViewController ");
}
- (void)yocAdViewWillDismissModalViewController:(YOCAdView *)yocAdView {
NSLog(@" yocAdViewWillDismissModalViewController ");
}
@end
請誰能幫給我的東西來嘗試,並找出如何讓廣告橫幅視圖從谷歌DFP響應返回點擊事件!?
埃裏克,我們終於破解了!非常感謝您的幫助。 –