2012-08-11 91 views

回答

0

因此,您必須編寫自己的代碼才能讓插頁式廣告發揮作用。看看這個插件,它看起來像只適用於橫幅。不知道你對Objective C開發有多熟悉,但我可以嘗試給你一個高層次的實現概述。

如果您想要,您可以創建一個新的插件,或者將其添加到現有的插件中。只是扔下來了我的頭,懷疑它會沒有編譯錯誤工作的頂部,等:

- (void) createInterstitial:(NSMutableArray *)arguments withDict:(NSMutableDictionary *)options 
{ 
    NSLog(@"Create Interstitial executed"); 
    // Make sure you create an adInterstitial property 
    if(self.adInterstitial) 
     return; 

    if([options objectForKey:@"siteId"]) 
    { 
     NSLog(@"Setting site Id"); 
     self.siteId=[[options objectForKey:@"siteId"] description]; 
    } 

    // Note that the GADBannerView checks its frame size to determine what size 
    // creative to request. 
    //Initialize the banner off the screen so that it animates up when displaying 
    self.adInterstitial = [[[GADInterstitial alloc] init] autorelease]; 
    // Note: Edit SampleConstants.h to provide a definition for kSampleAdUnitID 
    // before compiling. 
    self.adInterstitial.adUnitID = self.siteId; 
    self.adInterstitial.delegate = self; 

}

- (void) loadInterstitial:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options 
{  
    NSLog(@"Load interstitial executed"); 
    if(!self.adInterstitial) 
     [self createInterstitial:arguments withDict:options]; 

    GADRequest *request = [self createRequest]; 
    [self setLocation:&request withDict:options]; 
    [self.adInterstitial loadRequest:request]; 
} 

- (void)interstitialDidReceiveAd:(GADInterstitial *)interstitial { 
    [interstitial presentFromRootViewController:self]; 
    [self.webView stringByEvaluatingJavaScriptFromString:@"window.plugins.AdMob.adViewDidReceiveAdCallback();"]; 

} 

- (void)interstitial:(GADInterstitial *)interstitial 
    didFailToReceiveAdWithError:(GADRequestError *)error { 
    NSLog(@"Failed to receive ad with error: %@", [error localizedFailureReason]); 
    NSString* jsString = [NSString stringWithFormat:@"window.plugins.AdMob.didFailToReceiveAdWithErrorCallback(%@);", 
          [error localizedFailureReason]]; 
    [self.webView stringByEvaluatingJavaScriptFromString:jsString]; 
} 
+0

非常感謝上面的代碼:)我不太熟悉Obj C編程,但我確實知道其他語言。我會盡力檢查你的代碼,並編譯它。我的情況是如何的,我的問題已經有了一個內置的解決方案。 – 2012-09-16 14:08:29

相關問題