[![CI Status](https://img.shields.io/travis/Yu Yang/ZYAdKit.svg?style=flat)](https://travis-ci.org/Yu Yang/ZYAdKit)
##1.从后台读取配置
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[ServiceApi getConfig];
}
UserDefaults.standard.setValue(json, forKey: "kAdInfo")
UserDefaults.standard.synchronize()
AdManager.shared.cacheDatas()
##2.设置config
-
- 先设置config, 把要显示的
rootViewController
传过去
- 先设置config, 把要显示的
-
- 加载假的
launchView
, 和真的launchView
一摸一样的view
, 如上图
- 加载假的
-
- 获取占位的VC显示
-
- 未获取到, 则加载自己的
rootViewController
- 未获取到, 则加载自己的
let config = AdConfig()
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let mainVc = storyboard.instantiateInitialViewController()!
config.rootViewController = mainVc
AdManager.shared.setConfig(config)
let placeholderLaunchView = Bundle.main.loadNibNamed("PlaceholderLaunchView", owner: nil, options: nil)?.first as! UIView
if let placeholderLaunchVc = AdManager.shared.getPlaceholderViewController(with: placeholderLaunchView) {
window = UIWindow(frame: UIScreen.main.bounds)
window?.rootViewController = placeholderLaunchVc
} else {
window = UIWindow(frame: UIScreen.main.bounds)
window?.rootViewController = mainVc
}
window?.makeKeyAndVisible()
##3.在 info.plist 里设置admob key
<key>GADApplicationIdentifier</key>
<string>ca-app-pub-3940256099942544~1458002511</string>