【发布时间】: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>
还是没有运气,谁能告诉我我可能做错了什么?
【问题讨论】: