osdir.com
mailing list archive F.A.Q. -since 2001!

low ad version

Subject: [PhoneGap] SOLVED: Adding AdMob Ads Natively (no
plugins required) for iOS - msg#01233

List: phonegap

phonegap Navigation:
Date: Prev Next Date Index Thread: Prev Next Thread Index

I want to share this with the group because it seems that these
directions don't exist ANYWHERE. I'm not really sure what the big
secret is but I want to de-mystify it and hopefully save some others
precious time. It's really simple and Does Not involve installing any
phonegap plugins ;)

1.) Create your normal, everyday phonegap (1.0.0) project in xcode
2.) Import the GoogleAdMobAdsSDK folder and the required AdMob
frameworks (I believe the only one that wasn't already in the phonegap
project was MessageUI.framework)
3.) In AppDelegate.h - #import "GADBannerView.h" & add GADBannerView
*bannerView_; to your @interface
4.) In AppDelegate.m - #define MY_BANNER_UNIT_ID @"Your AdMob
Publisher ID# Here"

Now the tricky part. This caused me to bang my head on the wall for
some time . . .

5.) Change your method webViewDidFinishLoad to this . . .

- (void)webViewDidFinishLoad:(UIWebView *)theWebView
{
bannerView_ = [[GADBannerView alloc]init];
[bannerView_ setDelegate:self];
[bannerView_ setFrame:CGRectMake(0, 430, 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 ];
}


That's it.

I have created a sample project that does exactly this with the option
to display test ads.
You can download the project from
http://iphone.keyvisuals.com/downloads/AdGap.zip

Why does the banner view need to be created in the
webViewDidFinishLoad method? I think it's because phonegap doesn't
create the viewController until after the webview but I might be
wrong. This might not be the ideal solution for everyone's app but it
works for me. Enjoy.

--
You received this message because you are subscribed to the Google
Groups "phonegap" group.
To post to this group, send email to phonegap@xxxxxxxxxxxxxxxx
To unsubscribe from this group, send email to
phonegap+unsubscribe@xxxxxxxxxxxxxxxx
For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en

For more info on PhoneGap or to download the code go to www.phonegap.com

Thread at a glance:

Previous Message by Date:

[PhoneGap] Help : Blackberry Internet Service with phone gap

hi theres, as subject i wanna ask how to use blackberry internet service connection for my apps that use phone gap development? so my application will not using the wap connection that increasing the phone bill,so much thanks for your help :-), best regards -- You received this message because you are subscribed to the Google Groups "phonegap" group. To post to this group, send email to phonegap@xxxxxxxxxxxxxxxx To unsubscribe from this group, send email to phonegap+unsubscribe@xxxxxxxxxxxxxxxx For more options, visit this group at http://groups.google.com/group/phonegap?hl=en?hl=en   For more info on PhoneGap or to download the code go to www.phonegap.com

Next Message by Date:

[PhoneGap] Re: SOLVED: Adding AdMob Ads Natively (no plugins required) for iOS

BTW - I'm not affiliated in any way with AdMob. -- You received this message because you are subscribed to the Google Groups "phonegap" group. To post to this group, send email to phonegap@xxxxxxxxxxxxxxxx To unsubscribe from this group, send email to phonegap+unsubscribe@xxxxxxxxxxxxxxxx For more options, visit this group at http://groups.google.com/group/phonegap?hl=en?hl=en For more info on PhoneGap or to download the code go to www.phonegap.com

Previous Message by Thread:

[PhoneGap] Help : Blackberry Internet Service with phone gap

hi theres, as subject i wanna ask how to use blackberry internet service connection for my apps that use phone gap development? so my application will not using the wap connection that increasing the phone bill,so much thanks for your help :-), best regards -- You received this message because you are subscribed to the Google Groups "phonegap" group. To post to this group, send email to phonegap@xxxxxxxxxxxxxxxx To unsubscribe from this group, send email to phonegap+unsubscribe@xxxxxxxxxxxxxxxx For more options, visit this group at http://groups.google.com/group/phonegap?hl=en?hl=en   For more info on PhoneGap or to download the code go to www.phonegap.com

Next Message by Thread:

[PhoneGap] Re: SOLVED: Adding AdMob Ads Natively (no plugins required) for iOS

BTW - I'm not affiliated in any way with AdMob. -- You received this message because you are subscribed to the Google Groups "phonegap" group. To post to this group, send email to phonegap@xxxxxxxxxxxxxxxx To unsubscribe from this group, send email to phonegap+unsubscribe@xxxxxxxxxxxxxxxx For more options, visit this group at http://groups.google.com/group/phonegap?hl=en?hl=en For more info on PhoneGap or to download the code go to www.phonegap.com

Home | News | Sitemap | FAQ | advertise | OSDir is an Inevitable website. GBiz is too! | Ad Serving by nView.io