【问题标题】:Mopub Interstitial not loadingMopub 插页式广告未加载
【发布时间】:2017-05-30 08:16:18
【问题描述】:

我正在尝试使用 MoPub 教程中的测试 ID 测试 mopub 插页式广告,ios 版本是 10.2,MoPub 输出

2017-01-15 13:47:46.801224 Twit Miner[23775:6627095] MOPUB: Looking for custom event class named MPHTMLInterstitialCustomEvent.
2017-01-15 13:47:46.801321 Twit Miner[23775:6627095] MOPUB: Loading MoPub HTML interstitial
2017-01-15 13:47:46.999975 Twit Miner[23775:6627095] MOPUB: MoPub HTML interstitial did load

但我没有看到任何插页式广告正在显示。您可以在下面找到我的代码:

import UIKit
import MoPub

class ViewController: UIViewController
, MPInterstitialAdControllerDelegate

{
    // TODO: Replace this test id with your personal ad unit id
    var interstitial: MPInterstitialAdController =
        MPInterstitialAdController(forAdUnitId: "77ce0b65cf81438eb255695afe3b1904")

    override func viewDidLoad() {
        super.viewDidLoad()

        self.interstitial.delegate = self
        // Pre-fetch the ad up front
        self.interstitial.loadAd()
    }

    func interstitialDidLoadAd(interstitial: MPInterstitialAdController) {
        // This sample automatically shows the ad as soon as it's loaded, but
        // you can move this showFromViewController call to a time more
        // appropriate for your app.
        if (interstitial.ready) {
            interstitial.showFromViewController(self)
        }
    }
}

尽管日志提示不是这样,但当我设置断点时,我意识到 interstitialDidLoadAd 方法永远不会被调用。我认为这可能是由于 ATS,所以我在 info.plist 中添加了以下键:

<key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
        <key>NSAllowsArbitraryLoadsForMedia</key>
        <true/>
        <key>NSAllowsArbitraryLoadsInWebContent</key>
        <true/>
    </dict>

还是没有运气,谁能告诉我我可能做错了什么?

【问题讨论】:

    标签: ios mopub


    【解决方案1】:

    我意识到这可能为时已晚。

    检查您是否有以下日志条目:

    A location manager (0x143ebb150) was created on a dispatch queue 
    executing on a thread other than the main thread.  It is the 
    developer's responsibility to ensure that there is a run loop running 
    on the thread on which the location manager object is allocated.  In 
    particular, creating location managers in arbitrary dispatch queues 
    (not attached to the main queue) is not supported and will result in 
    callbacks not being received.
    

    就在之前:

    MOPUB: Interstitial controller is loading ad with MoPub server URL:
    

    如果是这样,请尝试像这样在主队列上调度 loadAd 方法。

    Objective-C

    dispatch_async(dispatch_get_main_queue(), ^{
        [self.interstitial loadAd];
    });
    

    斯威夫特 3

    DispatchQueue.main.async {
        self.interstitial.loadAd()
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多