AdMob Ad不会显示和崩溃ios

时间:2017-05-15 22:50:09

标签: ios swift firebase admob xcode7

我正在尝试在视图控制器上显示原生广告,但是当我导航到该视图控制器时,应用程序会因未捕获的异常而崩溃。广告单元ID也可以从广告收集中正确获取,广告是400 x 400的UIview。

L = {<M> | M is a TM that accepts w whenever it accepts w^R}

日志:

 import UIKit

 import GoogleMobileAds

class ViewController: UIViewController, GADNativeExpressAdViewDelegate, GADVideoControllerDelegate {

@IBOutlet weak var ads: GADNativeExpressAdView!

 let adUnitId = "ca-app-pub-1330625274650885/2836069451"

 override func viewDidLoad() {
    super.viewDidLoad()
    ads.adUnitID = adUnitId
  ads.rootViewController = self
  ads.delegate = self


    let videoOptions = GADVideoOptions()
    videoOptions.startMuted = true
   ads.setAdOptions([videoOptions])


 ads.videoController.delegate = self

    let request = GADRequest()
    request.testDevices = [kGADSimulatorID]

    ads.loadRequest(request) }

func nativeExpressAdViewDidReceiveAd(_ nativeExpressAdView: GADNativeExpressAdView) {
    if nativeExpressAdView.videoController.hasVideoContent() {
        print("Received an ad with a video asset.")
    } else {
        print("Received an ad without a video asset.")
    }
}

func videoControllerDidEndVideoPlayback(_ videoController: GADVideoController) {
    print("The video asset has completed playback.")
}}

0 个答案:

没有答案