我正在使用this AdMob plugin for phonegap并且它工作正常吗?你可以read here how I did it if you need。我的问题是如何使用此插件为我的iOS应用创建插页式广告(占据整个屏幕)?
感谢您的帮助!
答案 0 :(得分: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];
}