PhoneGap iAds Plugin
Hey its a new plugin for PhoneGap. I call it the “PhoneGap AdPlugin”, and even though it only supports iAds currently, there is potential for supporting the other ad networks as a backup to iAds. Make sure you read the RELEASE NOTES in the README for limitations.
Get the source and view the README
Below are screenshots from the test app included, called ‘iAdHost’
Advertisement


Great! Thank u very much!
Daniel Kim
July 13, 2010 at 1:28 am
Great news! Do you need the ‘edge’ version of phonegap to get this working or will plug-ins work on the current 1.9.1 release?
Jimmy Fountain
July 13, 2010 at 3:26 pm
Should work with current release.
shazron
July 13, 2010 at 4:04 pm
Could you post your HTML for the Phonegap HTML file shown in the windows above?
Scott
July 16, 2010 at 5:31 am
It’s in the source, if you read the README. http://github.com/shazron/PhoneGap-Plugins/tree/master/AdPlugin/iPhone/iAdHost/www/
shazron
July 16, 2010 at 5:33 am
The Apple iAd docs (http://developer.apple.com/iphone/prerelease/library/documentation/UserExperience/Conceptual/iAd_Guide/Introduction/Introduction.html) says “While an advertisement is displayed, your application’s activities should be scaled back, and features that require the user to see or hear the user interace should be suspended.”.
How can I detect that the ad was clicked so I can pause the game music I have playing and pause the game?
Russ
August 8, 2010 at 3:02 pm
@russ
Might be in the next feature update – I have to hook into the native callbacks and send out DOM events to the UIWebView.
shazron
August 27, 2010 at 9:44 am
How can i check when Advertisements are Not Available ?
Giulio
September 4, 2010 at 3:49 pm
@Giulio
Check out the updated code, and www/index.html – it should handle that event.
shazron
October 8, 2010 at 10:58 pm
@Shazron, thanks for your reply. I’ll try it
Giulio
October 9, 2010 at 11:02 am
Hi Shazron,
thanks for a great plugin, problem is I can’t get the demo project to compile ;(
I’ve followed the readme to the letter, a handful of times, the project zip is here:
http://www.jm3d.co.uk/iAdHost.zip
The error I’m getting is:
cp ../*.js /Users/imacapple/Work/iAdHost/www/
cp: ../*.js: No such file or directory
And I really can’t see what I’m doing wrong… would you mind taking a look please? It would be a great help.
I saw this guide – should I be making these changes also:
http://www.zeletron.com.br/2010/07/adding-iad-in-phonegap-apps.html
Thanks a lot
Jamie
Jamie McDonnell
October 28, 2010 at 8:08 pm
The demo project is just that, a demo.
If you created a new project and did what you did according to the readme, it should be fine.
Don’t use iAdHost as your base.
shazron
October 28, 2010 at 9:43 pm
Anyone know of any support for YOC Network and Phonegap? http://group.yoc.com/uk/
Rascaltester
February 7, 2011 at 5:47 pm
Is it possible to show iAds using Sencha + Phonegap + PhoneGap AdPlugin ?
Jack
June 23, 2011 at 5:09 pm
Yeah, the iAds plugin is outside of the WebView.
shazron
June 24, 2011 at 10:38 pm
Hi Shazron,
I followed all steps, but nothing is showing up. No errors. The app works fine, but I don’t see the ad. What could I be doing wrong?
Thank you!
claras
September 21, 2011 at 6:26 am
Don’t know really. I’ve often had the problem — Apple is just not serving ads even the test ones sometimes.
shazron
September 22, 2011 at 11:23 pm
HI,
Thanks for the tut but one question:
How do get the ads to show up below my app and not ontop of it, I have a row of buttons on the bottom of my app but the ads show up on top of them thereby blocking them from the view and use. If I just add an extra 50px to the bottom of my app then that is wasted space if there is no app to show.
here is what my appdelagate.h and .m look like now:
#import “iAd/iAd.h”
@interface AppDelegate : PhoneGapDelegate {
NSString* invokeString;
BOOL bannerIsVisible;
}
@property (copy) NSString* invokeString;
@property (nonatomic,retain) IBOutlet ADBannerView *adView;
@property BOOL bannerIsVisible;
and .m:
@implementation AppDelegate
@synthesize invokeString;
@synthesize adView;
//@property (nonatomic,retain) IBOutlet ADBannerView *adView;
@synthesize bannerIsVisible;
……
- (void)webViewDidFinishLoad:(UIWebView *)theWebView
{
// only valid if DromeiOS.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];
}
bannerIsVisible = YES;
//ADBannerView * ############ NOTICE THIS CHANGE ############
adView = [[ADBannerView alloc] initWithFrame:CGRectZero];
adView.frame = CGRectMake(0, 410, 320, 50); // if you want the banner to be on top of the screen remove this line
adView.delegate = self;
adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;//ADBannerContentSizeIdentifier320x50;
[theWebView addSubview:adView];
return [ super webViewDidFinishLoad:theWebView ];
}
……
NewbieDan
October 3, 2011 at 6:44 pm
ok, I added code to my showAd methoid to show/hide an extra div at the bottom of my app if showAd(true) is called, trouble is even if showAd(false) is called the ad banner still pops up (test ad) and my div.hide() gets called and my buttons are hidden again. Is there a more reliable way to detect when the ad banner is shown and when it is hidden?
NewbieDan
October 4, 2011 at 4:52 pm