2012-07-20 7 views
5

Mam aplikację phonegap i próbuję implementować AdMob.Jak zaimplementować AdMob w Phonegapie

używam wersji 1.4.1 PhoneGap i używam tej witryny jak mój odniesienia: http://iphone.keyvisuals.com/iphonedev/implementing-admob-ads-in-a-phonegap-project-for-ios-no-plugins-required/

Moje kodu jest w następujący sposób:

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

Wszystko jest w porządku, ale gdy używam aplikacja, nie są wyświetlane żadne reklamy.

Odpowiedz

0

Upewnij się, że Twój obiekt "theWebView" zakończył ładowanie. I że bannerView_ jest zarejestrowaną własnością twojego obiektu.

Mam również nadzieję, że po prostu wstawiasz "MY_BANNER_UNIT_ID", aby ukryć identyfikator swojej jednostki banerowej.

Sprawdź swoje ustawienia admora, jeśli identyfikator jednostki banerowej jest prawidłowy.

Na koniec użyj serwera proxy iPhone'a, takiego jak Charles lub podobny, aby sprawdzić, czy wywołanie jest prawidłowe.

0

Phonegap został zaktualizowany. Obsługuje nowe funkcje. po prostu dodaj ten kod do swojej konfiguracji.

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