2012-07-20 13 views
5

Tengo una aplicación de phonegap y estoy tratando de implementar Admob.Cómo implementar AdMob en Phonegap

estoy usando PhoneGap versión 1.4.1 y estoy usando este sitio como mi referencia: http://iphone.keyvisuals.com/iphonedev/implementing-admob-ads-in-a-phonegap-project-for-ios-no-plugins-required/

Mi código es el siguiente:

(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 ]; 
} 

Todo está bien, pero cuando estoy corriendo la aplicación, no se muestran anuncios.

Respuesta

0

Asegúrese de que su objeto "theWebView" finaliza su carga web. Y que el bannerView_ es una propiedad registrada de su objeto.

Además, espero que simplemente coloque "MY_BANNER_UNIT_ID" para ocultar su id. De pancarta.

Compruebe con la configuración de su admob si la id del pancarta es correcta.

Y, por último, utilice un proxy de iphone como Charles o similar para validar que la llamada se apaga como debería.

0

Phonegap se ha actualizado. Admite nuevas funciones. solo agrega este código en tu configuración.

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