[AdMob] 내가 만든 앱에 배너광고 넣기

2016. 8. 26. 16:24Programming/Swift

반응형

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.

    }







반응형

'Programming > Swift' 카테고리의 다른 글

한글/영문/숫자 순으로 정렬하기.  (0) 2016.08.29
[Firebase] firebase/crash 설정  (0) 2016.08.27
UIViewController 라이프사이클 다이어그램  (0) 2016.08.22
Multi Return Values  (0) 2016.08.12
collectionView cell 이동  (0) 2016.08.04