gpt4 book ai didi

iphone - 如何在 Phonegap 中实现 AdMob

转载 作者:可可西里 更新时间:2023-11-01 05:00:12 26 4
gpt4 key购买 nike

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

我使用的是 phonegap 版本 1.4.1 并且我使用这个网站作为我的引用:http://iphone.keyvisuals.com/iphonedev/implementing-admob-ads-in-a-phonegap-project-for-ios-no-plugins-required/

我的代码如下:

(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”对象完成其网络加载。并且 bannerView_ 是您对象的注册属性。

此外,我希望您只输入“MY_BANNER_UNIT_ID”来隐藏您的横幅广告单元 ID。

如果横幅单元 ID 正确,请检查您的 admob 设置。

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

关于iphone - 如何在 Phonegap 中实现 AdMob,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11580950/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com