2017-08-09 6 views
0

xcodeでiOSアプリを作成しました。私はwebviewを使用しています。私は既にGoogleのadmobバナー広告を実装していますが、今でもボタンをクリックせずにインタースティシャル広告を表示したいのです。 urlはインタースティシャル広告を表示します。私はこのコードを使用しますが、インタースティシャル広告Xcode 8

interstitial = GADInterstitial(adUnitID: "") 
    let request = GADRequest() 
    // Request test ads on devices you specify. Your test device ID is printed to the console when 
    // an ad request is made. 
    request.testDevices = [ kGADSimulatorID, "2077ef9a63d2b398840261c8221a0c9b" ] 
    interstitial.load(request) 

    if interstitial.isReady { 
     interstitial.present(fromRootViewController: self) 
    } else { 
     print("Ad wasn't ready") 
    } 

とAppDelegate.m

FirebaseApp.configure() 

しかし広告が、私はXcodeのログにエラーが表示されないことができ、表示されません作品ではないのです、私を助けてください、お礼

答えて

0

AppDelegateを「GoogleMobileAds」にインポートしてGADInterstitialDelegateに接続しないでください。そして、あなたのIDが該当する場合、AppDelegateでこれを試してみてください。

var interstitial: GADInterstitial! 
    var window: UIWindow? 

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 

    GADMobileAds.configure(withApplicationID: "yourApplicationID") 
    return true 
} 

func showInterstitial(_ notification: NSNotification) { 

    interstitial = GADInterstitial(adUnitID: "youradUnitID") 
    let request = GADRequest() 
    interstitial.delegate = self 
    // Request test ads on devices you specify. Your test device ID is printed to the console when 
    // an ad request is made. 
    //request.testDevices = [ kGADSimulatorID, "2077ef9a63d2b398840261c8221a0c9b" ] 
    interstitial.load(request) 
} 

func interstitialDidReceiveAd(_ ad: GADInterstitial) { 

    if(self.interstitial.isReady){ 
     interstitial.present(fromRootViewController: (self.window?.rootViewController)!) 

    } 
} 

func interstitialDidFail(toPresentScreen ad: GADInterstitial) { 
    NSLog("") 
} 

エラーがある場合は、コンソール

に失敗したことを表示することができます
関連する問題