Introduction
Is it a real fact or just a rumor…I’m not sure yet…but:
- iAd is not yet available in all countries but has a higher earning per impression and click-through
- AdMob is available in almost every country but with a lower earning rate per impression and click-through
So why not just combine both?
You can
check the resullt with the free stopwatch application:
Or you can download a zip
file from the project to use as a starting point.
Or you can visit the repository on
Github.
It may look like a complex task but it is rather easy to accomplish. I will not fully explain how to setup iAd neither how to setup AdMob, but I will provide the directions on how to make both advertising platform work nicely together so you can maximize your
earnings.
The Banner Views
Make sure to extend your view controller with two data member:
1
2
|
ADBannerView GADBannerView |
and your UIViewController should implement two protocols:
1
|
UIViewController<ADBannerViewDelegate, |
Create an init method for the iAd banner that will place the banner on the bottom out of view, so it becomes possible to slide it into view with a nice animation:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
-( void )initiAdBanner { if
{ // CGSize // iAdBannerView self.view.frame.size.height, bannerSize.width, bannerSize.height)]; iAdBannerView.delegate iAdBannerView.hidden [self.view } } |
Lets do the same for the AdMob banner:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
-( void )initAdMobBanner { if
{ // adMobBannerView initWithFrame:CGRectMake(0.0, self.view.frame.size.height, GAD_SIZE_320x50.width, GAD_SIZE_320x50.height)]; adMobBannerView.adUnitID "YOUR_ID" ; adMobBannerView.hidden adMobBannerView.rootViewController [self.view } } |
Hide and show animation
1
2
3
4
5
6
7
8
9
10
11
|
-( void )hideBanner:(UIView*)banner { if
![banner { [UIView "animatedBannerOff"
banner.frame [UIView banner.hidden } } |
1
2
3
4
5
6
7
8
9
10
11
|
-( void )showBanner:(UIView*)banner { if
[banner { [UIView "animatedBannerOn"
banner.frame [UIView banner.hidden } } |
The Delegate methods
Now it is time to implement the delegate methods for the iAd banner, make sure to request for AdMob when loading did fail:
1
2
3
4
5
6
7
8
9
10
11
12
13
|
-( void )bannerViewDidLoadAd:(ADBannerView { [self [self } - void )bannerView:(ADBannerView { // [adMobBannerView [self [self } |
And finally the AdMob delegates:
1
2
3
4
5
6
7
8
9
10
11
|
- void )adViewDidReceiveAd:(GADBannerView { if
[self } } - void )adView:(GADBannerView { [self } |
You can
check the resullt with the free stopwatch application: