2012-07-20 12 views
5

私はphonegapアプリケーションを持っていて、Admobを実装しようとしています。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 ]; 
} 

すべてが細かいですが、私は実行しているときアプリケーションでは、広告は表示されません。

答えて

0

「theWebView」オブジェクトがWebloadを終了していることを確認してください。そして、bannerView_はあなたのオブジェクトの登録されたプロパティです。

また、「MY_BANNER_UNIT_ID」を入れてバナーユニットIDを非表示にしてください。

バナーユニットIDが正しい場合は、admob設定で確認してください。

最後に、チャールズなどのiphoneプロキシを使用して、コールが外出することを検証してください。

0

電話番号がアップグレードされました。それは新しい機能をサポートします。あなたの設定でこのコードを追加するだけです。

<gap:plugin name="com.admob.plugin" version="1.0.0" source="plugins.cordova.io"/> 
関連する問題