第一步:註冊帳號
首先你得上KeyMob官網註冊帳號,由KeyMob移動廣告聚合平臺提供給你的ID與Key。
第二步:下載 KeyMob SDK
a.導入swift項目 b.解壓KeyMob SDK 文件 c.在storyboard中添加一塊view,並設置好佈局 d.選擇Class
第三步:編輯代碼
import UIKit
Import Google Mobile Ads
Class viewcontroller:UIViewController{
@IBoutlet weak var bannerView:GADBannerView!
Override func viewDidLoad(){
super.viewDidLoad()
bannerView.adUnitId=「ca-app-pub-706657930853688714815911455」
bannerView.rootViewController=self
self.view.addSubView(bannerView)
Var request:GADRequest=GADRequest()
request.testDevices={「」}
bannerView.loadRequest(request)
}
Override func didReceivwMemoryWarning(){
super.didReceiveMemoryWarning()
}
}
import UIKitimport GoogleMobileAds
class ViewController: UIViewController {
@IBOutlet weak var bannerView: GADBannerView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
bannerView.adUnitID = "你的廣告ID"
bannerView.rootViewController = self
self.view.addSubview(bannerView)
var request:GADRequest = GADRequest()
equest.testDevices = [""]
bannerView.loadRequest(request)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
第四步:測試廣告
KeyMob移動廣告聚合平臺:是專門爲專業的移動應用廣告管理工具,支持國內外多家移動廣告聚合平臺自由轉換(包括:果合、芒果、抓貓、Adview等)。KeyMob在幫助開發者輕鬆集成多家移動廣告聚合平臺的同時,應用交叉推廣,大幅提高廣告填充率,實現廣告收入最大化。swift