Ios Google AdMobs自定义单击事件不适用于不受支持的网络
我正在使用Google AdMobs DFP从其他网络提供调解横幅。我已经添加了Millennial和InMobi fine,但现在我需要添加一个没有DFP适配器的网络(YOC group),因此我需要实现“自定义事件横幅”。我已经阅读了关于使用自定义事件实现不受支持的中介网络的指南和技术文档,但仍然无法理解它如何连接两个SDK(Google AdMobs SDK和中介网络的SDK) 如果我将YOC广告id(格式为'9A9A99999A999A9A9A9A99A99A9A9A99A99A9A9A99AA99AA99AA99A999A9Aa')硬编码到示例广告并发送请求,则没有适配器(YOC)的网络可以工作。横幅恢复良好,并使用YOC SDK显示交互式/富媒体广告 但是,在我的应用程序中,我只有一个Google DFP帐户id(格式为“/9999/company.app/channel”),我向DFP发送了使用Google AdMobs SDK的请求。然后,请求返回特定中介广告网络的响应,以尝试从中请求横幅广告。我目前的设置是YOC在DFP中提供100%的广告 问题:我从YOC广告网络收到一条横幅广告,并显示在屏幕上。它注册页面印象(使用DFP),但对触摸/按下事件没有响应,就像我硬编码yoc ad视图的初始化参数一样。然而,我不能硬编码yoc广告id(初始化时),因为它只适用于一个横幅广告,我需要为每个频道中的每个特定广告使用不同的横幅 下面是我试图实现的示例代码,它仅使用方法中的nslog来登录到控制台,并显示正在调用这些方法。这是一个非常基本的应用程序,将所有代码放在一个地方,便于阅读 AppDelegate.hIos Google AdMobs自定义单击事件不适用于不受支持的网络,ios,objective-c,admob,google-dfp,custom-events,Ios,Objective C,Admob,Google Dfp,Custom Events,我正在使用Google AdMobs DFP从其他网络提供调解横幅。我已经添加了Millennial和InMobi fine,但现在我需要添加一个没有DFP适配器的网络(YOC group),因此我需要实现“自定义事件横幅”。我已经阅读了关于使用自定义事件实现不受支持的中介网络的指南和技术文档,但仍然无法理解它如何连接两个SDK(Google AdMobs SDK和中介网络的SDK) 如果我将YOC广告id(格式为'9A9A99999A999A9A9A9A99A99A9A9A99A99A9A9A
#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
#导入
#导入“gadbanerview.h”
#导入“gadbanerviewdelegate.h”
#导入“GADCustomEventBanner.h”
#导入“GADCustomEventBannerDelegate.h”
#导入
@接口AppDelegate:UIResponder
@属性(强,非原子)UIWindow*window;
@属性(强,非原子)UIViewController*根;
@结束
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/channel_specific_id";
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/channel_specific_id)'
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/channel_specific_id'
[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
#导入“AppDelegate.h”
#导入“gadbanerview.h”
#进口
@实现AppDelegate
@合成根;
@综合委托;//GADCustomEventBanner在GADCustomEventBanner上设置Legate
-(BOOL)应用程序:(UIApplication*)应用程序使用选项完成启动:(NSDictionary*)启动选项
{
CGRect界限=[[UIScreen mainScreen]界限];
self.window=[[UIWindow alloc]initWithFrame:bounds];
self.window.backgroundColor=[UIColor greenColor];
GADBannerView*banner=[[GADBannerView alloc]initWithAdSize:kGADAdSizeLeaderboard原点: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;
//adUnitID始终是我们的DFP账号,格式为“/9999/company.app/aa_aa_app”
banner.adUnitID=@“/9999/company.app/channel_-specific_-id”;
banner.delegate=self;
banner.rootViewController=self.root;
self.delegate=self;
[基本添加子视图:横幅];
[base bringSubviewToFront:banner];
[banner loadRequest:[GADRequest]];
[self.windowsetRootViewController:self.root];
[[UIApplication sharedApplication]设置StatusBarHidden:YES with Animation:UIStatusBaranimationne];
[self.window makeKeyAndVisible];
返回YES;
}
#布拉格语标记GADBannerViewDelegate
-(无效)AdviewIDReceiveAD:(GADBannerView*)视图{
NSLog(@“adViewDidReceiveAd”);
NSLog(@“视图:%@,[视图描述]);
//对于其他广告网络,我们得到view.mediatedAdView=IMAdView(InMobi)或view.mediatedAdView=MMAdView(千禧年版),但使用YOC view.mediatedAdView=nil;
[self.delegate customEventBanner:self-didReceiveAd:view];
}
-(void)adView:(GADBannerView*)视图未能接收到带有错误的数据:(GADRequestError*)错误{
NSLog(@“DIDFILETORECEIVEADWITHERROR”);
[self.delegate customEventBanner:self-didFailAd:error];
}
-(无效)adViewWillPresentScreen:(GadbanerView*)adView{
NSLog(@“adViewWillPresentScreen”);
[self.delegate customEventBanner:self-clickdidconcurinad:adView];
[self.delegate CustomEventBannerWillPresentModel:self];
}
-(无效)adViewWillDismissScreen:(GadbanerView*)adView{
NSLog(@“adViewWillDismissScreen”);
[self.delegate customEventBannerWillDismissModal:self];
}
-(无效)AdviewIDDismissScreen:(GadbanerView*)adView{
NSLog(@“adViewDidDismissScreen”);
[self.delegate CustomEventBannerdIsMissModel:self];
}
-(作废)adViewWillLeaveApplication:(GadbanerView*)adView{
NSLog(@“adViewWillLeaveApplication”);
[self.delegate customEventBannerWillLeaveApplication:self];
}
#布拉格马克·加德班纳
-(void)requestBannerAd:(GADAdSize)adSize
参数:(NSString*)服务器参数
标签:(NSString*)服务器标签
请求:(GADCustomEventRequest*)请求{
NSLog(@“requestBannerAd”);
//不确定我们是否在此处初始化YOC标记,或者如果无法将yocTag硬编码为格式“9A9A9A999999A999A999A9A9A9A99AA99AA99AA999A9A9A9A9A9A9A99AA99AA99AA999A9AA”,我们将如何进行初始化
//我们只有从DFP返回的标题视图,id为“/9999/company.app/channel\u specific\u id”
YOCAdView*YOCAdView=[[YOCAdView alloc]initWithYOCTag:serverParameter委托:自身大小:kLeaderboard728x90位置:CGPointMake(0,0)];
yocAdView.delegate=self;
[yocAdView负载];
[self.root.view addSubview:yocAdView];
}
#pragma mark GADCustomEventBannerDelegate
-(无效)customEventBanner:(id)customEvent didReceiveAd:(UIView*)视图{
NSLog(@“[(GadbanerView*)视图调整ID]:%@“,[(GadbanerView*)视图调整ID]);
NSLog(@“[(GadbanerView*)视图委托]:%@”,
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)
@synthesize delegate
self.delegate
- (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];
}