我试着用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)
}
}
}尽管log提出了相反的建议,但当我放置一个断点时,我意识到从未调用过interstitialDidLoadAd方法。我认为这可能是由ATS造成的,所以我向info.plist添加了以下密钥:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSAllowsArbitraryLoadsForMedia</key>
<true/>
<key>NSAllowsArbitraryLoadsInWebContent</key>
<true/>
</dict>还是没有运气,有人能告诉我我可能做错了什么吗?
发布于 2017-07-20 13:40:49
我意识到这可能太迟了。
检查是否有以下日志条目:
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方法。
目标-C
dispatch_async(dispatch_get_main_queue(), ^{
[self.interstitial loadAd];
});Swift 3
DispatchQueue.main.async {
self.interstitial.loadAd()
}https://stackoverflow.com/questions/41660347
复制相似问题