[AdMob] 내가 만든 앱에 배너광고 넣기
https://firebase.google.com/docs/admob/ios/quick-start
* Podfile
source 'https://github.com/CocoaPods/Specs.git' platform :ios, '9.0' use_frameworks! pod 'Firebase/Core' pod 'Firebase/AdMob' target 'Demo' do pod 'Firebase' end |
$ pod install
* AppDelegate.swift
import Firebase import UIKit @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Override point for customization after application launch.
FIRApp.configure() GADMobileAds.configureWithApplicationID("ca-app-pub-3940256099942544/2934735716") return true } |
* ViewController.swift
import GoogleMobileAds class ViewController: UIViewController {
@IBOutlet weak var bannerView: GADBannerView! override func viewDidLoad() { super.viewDidLoad() //print("Google Mobile Ads SDK version: \(GADRequest.sdkVersion())") bannerView.adUnitID = "ca-app-pub-3940256099942544/2934735716" bannerView.rootViewController = self bannerView.loadRequest(GADRequest()) // Do any additional setup after loading the view, typically from a nib.
} } |