Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/93.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 如何在Phonegap中实现AdMob_Iphone_Ios_Cordova_Admob - Fatal编程技术网

Iphone 如何在Phonegap中实现AdMob

Iphone 如何在Phonegap中实现AdMob,iphone,ios,cordova,admob,Iphone,Ios,Cordova,Admob,我有一个phonegap应用程序,我正在尝试实现Admob 我正在使用phonegap版本1.4.1,我正在使用此网站作为参考: 我的代码如下: (void)webViewDidFinishLoad:(UIWebView *)theWebView { bannerView_ = [[GADBannerView alloc]init]; [bannerView_ setDelegate:self]; [bannerView_ setFrame:CGRectMake(0, 0, 320, 50)]

我有一个phonegap应用程序,我正在尝试实现Admob

我正在使用phonegap版本1.4.1,我正在使用此网站作为参考:

我的代码如下:

(void)webViewDidFinishLoad:(UIWebView *)theWebView
{

bannerView_ = [[GADBannerView alloc]init];
[bannerView_ setDelegate:self];
[bannerView_ setFrame:CGRectMake(0, 0, 320, 50)];

// Specify the ad's "unit identifier." This is your AdMob Publisher ID.
bannerView_.adUnitID = MY_BANNER_UNIT_ID;

// Let the runtime know which UIViewController to restore after taking
// the user wherever the ad goes and add it to the view hierarchy.
bannerView_.rootViewController = self.viewController;
[self.viewController.view addSubview:bannerView_];

// Initiate a generic request to load it with an ad.
[bannerView_ loadRequest:[GADRequest request]];

// only valid if AdGap.plist specifies a protocol to handle
if(self.invokeString)
{
    // this is passed before the deviceready event is fired, so you can access it in js when you receive deviceready
    NSString* jsString = [NSString stringWithFormat:@"var invokeString = \"%@\";", self.invokeString];
    [theWebView stringByEvaluatingJavaScriptFromString:jsString];
}
return [ super webViewDidFinishLoad:theWebView ];
}

一切都很好,但是当我运行应用程序时,没有显示任何广告

请确保您的“theWebView”对象完成其Web加载。并且bannerView是您的对象的注册财产

另外,我希望你只需要输入“我的旗帜单位ID”来隐藏你的旗帜单位ID

如果标题单元id正确,请检查admob设置


最后,请使用类似Charles或类似的iphone代理来验证通话是否正常进行。

Phonegap已升级。它支持新功能。只需在配置中添加此代码

<gap:plugin name="com.admob.plugin" version="1.0.0" source="plugins.cordova.io"/>