apple , google 广告
来源:互联网 发布:网管控制软件 编辑:程序博客网 时间:2024/05/07 10:13
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:
ADBannerView *iAdBannerView;
GADBannerView *adMobBannerView;
and your UIViewController should implement two protocols:
UIViewController<ADBannerViewDelegate, GADBannerViewDelegate>
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:
-(
void
)initiAdBanner
{
if
(!iAdBannerView)
{
// Get the size of the banner in portrait mode
CGSize bannerSize = [ADBannerView sizeFromBannerContentSizeIdentifier:ADBannerContentSizeIdentifierPortrait];
// Create a new bottom banner, will be slided into view
iAdBannerView = [[ADBannerView alloc]initWithFrame:CGRectMake(0.0,
self.view.frame.size.height,
bannerSize.width,
bannerSize.height)];
iAdBannerView.delegate = self;
iAdBannerView.hidden = TRUE;
[self.view addSubview:iAdBannerView];
}
}
Lets do the same for the AdMob banner:
-(
void
)initAdMobBanner
{
if
(!adMobBannerView)
{
// Create a new bottom banner, will be slided into view
adMobBannerView = [[GADBannerView alloc]
initWithFrame:CGRectMake(0.0,
self.view.frame.size.height,
GAD_SIZE_320x50.width,
GAD_SIZE_320x50.height)];
adMobBannerView.adUnitID = @
"YOUR_ID"
;
adMobBannerView.hidden = TRUE;
adMobBannerView.rootViewController = self;
[self.view addSubview:adMobBannerView];
}
}
Hide and show animation
-(
void
)hideBanner:(UIView*)banner
{
if
(banner &&
![banner isHidden])
{
[UIView beginAnimations:@
"animatedBannerOff"
context:nil];
banner.frame = CGRectOffset(banner.frame, 0, banner.frame.size.height);
[UIView commitAnimations];
banner.hidden = TRUE;
}
}
-(
void
)showBanner:(UIView*)banner
{
if
(banner &&
[banner isHidden])
{
[UIView beginAnimations:@
"animatedBannerOn"
context:nil];
banner.frame = CGRectOffset(banner.frame, 0, -banner.frame.size.height);
[UIView commitAnimations];
banner.hidden = FALSE;
}
}
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:
-(
void
)bannerViewDidLoadAd:(ADBannerView *)banner
{
[self hideBanner:adMobBannerView];
[self showBanner:iAdBannerView];
}
- (
void
)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
// Only request adMob when iAd did fail
[adMobBannerView loadRequest:[GADRequest request]];
[self hideBanner:iAdBannerView];
[self showBanner:adMobBannerView];
}
And finally the AdMob delegates:
- (
void
)adViewDidReceiveAd:(GADBannerView *)banner
{
if
([iAdBannerView isHidden]) {
[self showBanner:banner];
}
}
- (
void
)adView:(GADBannerView *)banner didFailToReceiveAdWithError:(GADRequestError *)error;
{
[self hideBanner:banner];
}
You can check the resullt with the free stopwatch application:
- apple , google 广告
- google广告
- Google 广告
- IBM 、M$ 、Google & Apple
- UnityInAppPurchase(Apple&Google)
- Google 广告 全面解析
- Google 广告定位技术
- 日进斗金的Google广告
- 试验google广告
- 离线的GOOGLE 广告
- GOOGLE广告连接示例
- 测试一下google广告
- 通过google广告赚钱
- 解密Google广告
- 有关GOOGLE广告作弊
- 屏蔽 Google AdSense 广告
- google 广告条代码
- Google的创意广告
- 匈牙利算法
- 安装SDK时遇到"Done loading packages"解决变法
- socket几种工作模式
- 使用imp/impdb和管道实现数据库的快速迁移
- 【js与jquery】注册会员时密码强度提示信息的制作
- apple , google 广告
- 中国邮路问题 ZOJ1903
- poj 2348(博弈)
- UITableView 基本使用方法总结
- 入侵系统之后给自己擦足迹
- linux tr命令参数及用法详解---删除文件中控制字符或进行字符转换
- Linux配置java环境变量(详细)
- 五种在linux下显示分区文件系统类型的方法
- [Linux] undefined reference to `itoa'