首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Mopub间质非加载

Mopub间质非加载
EN

Stack Overflow用户
提问于 2017-01-15 10:59:50
回答 1查看 703关注 0票数 1

我试着用mopub教程中的测试id测试MoPub间隙,ios版本是10.2,MoPub输出

代码语言:javascript
复制
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

但我没看到任何间隙广告。您可以在下面找到我的代码:

代码语言:javascript
复制
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)
        }
    }
}

尽管log提出了相反的建议,但当我放置一个断点时,我意识到从未调用过interstitialDidLoadAd方法。我认为这可能是由ATS造成的,所以我向info.plist添加了以下密钥:

代码语言:javascript
复制
<key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
        <key>NSAllowsArbitraryLoadsForMedia</key>
        <true/>
        <key>NSAllowsArbitraryLoadsInWebContent</key>
        <true/>
    </dict>

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

EN

回答 1

Stack Overflow用户

发布于 2017-07-20 13:40:49

我意识到这可能太迟了。

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

代码语言:javascript
复制
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.

就在此之前:

代码语言:javascript
复制
MOPUB: Interstitial controller is loading ad with MoPub server URL:

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

目标-C

代码语言:javascript
复制
dispatch_async(dispatch_get_main_queue(), ^{
    [self.interstitial loadAd];
});

Swift 3

代码语言:javascript
复制
DispatchQueue.main.async {
    self.interstitial.loadAd()
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41660347

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档