[PS: 前段時間,公司做ASO推廣,需要在應用中收集IDFA值,跟廣告平台做交互!於是有了這個需求~~]
1、首先,考慮了一下情況(自己懶 -_-#),就直接在首頁上寫了一個Banner,循環加載廣告[都是自己公司的一些廣告消息];
然后,就過了審核![萬事大吉]
這里打個小廣告,自己簡單封裝了一個MBAdBanner小框架,已經上傳到GitHub上了。
2、然后,最近更新版本的時候,由於收集IDFA而沒有實質性廣告就杯具了。果斷的大大紅色Reject!
DONE: 加入了一些其他平台的廣告(*東6.18活動等),作為收集IDFA使用。
3、最后,嫌棄麻煩,就導入了第三方的廣告服務[AdMob]
(1)利用CocoaPods, [ pod 'GoogleMobileAds', '~> 7.8.0' ];
--需要VPN才行。
(2)終端pod search GoogleMobileAds,找到 - Source: https://www.gstatic.com/cpdc/f5ae88269a942f37-GoogleMobileAds-7.8.0.tar.gz,將GoogleMobileAds.framework下載下來
--官網上沒有需要加入的框架文檔,只能從更新的版本中找到;
--如下:
(3)集成Banner代碼
// 導入
@import GoogleMobileAds;
// 聲明變量
@property (nonatomic, strong) GADBannerView *bannerView;
// viewDidLoad 中加入核心代碼
- (void)viewDidLoad { self.bannerView = [[GADBannerView alloc] initWithFrame:CGRectMake(0, 0, 320, 50)]; // self.bannerView.frame = CGRectMake(0, 0, 320, 50); self.bannerView.adUnitID = @"ca-app-pub-8372750357813473/1825818546"; // test. // self.bannerView.adUnitID = @"ca-app-pub-3940256099942544/2934735716"; self.bannerView.rootViewController = self; [self.bannerView loadRequest:[GADRequest request]];// 在需要的時候request,刷新顯示廣告![上架后,通過接口,關閉廣告服務即可] [self.view addSubview:_bannerView]; }
[ PS:額外提示]
1、這其中的adUnitID,是有google的AdMob后台提供的。
2、還有插屏廣告服務的接入等。
官網文檔地址:https://firebase.google.com/docs/admob/ios/quick-start
------------------------
iOS10 重大更新!
In iOS 10.0 and later, the value of advertisingIdentifier is all zeroes when the user has limited ad tracking.
在iOS10.0 beta版中,idfa這個值,將在用戶打開“廣告追蹤限制”后,獲取的值為全零! “0000-0000-00000-00000-0000”
------------------------