ios - 我想在 ios 中每五分钟加载一次 facebook 插页式广告(swift)

标签 ios swift facebook

我在viewdidload方法中添加了以下代码

self.interstitialAd = FBInterstitialAd.init(placementID: "")
self.interstitialAd.delegate = self;
interstitialAd.load()

以及每五分钟加载广告的调用时间

Timer.scheduledTimer(timeInterval: 300.0, target: self, selector: #selector(callInterstitialAdEveryFiveMinutes), userInfo: nil, repeats: true)
@objc func callInterstitialAdEveryFiveMinutes()  {
    interstitialAd.load()
}

但没有每五分钟展示一次广告并给出错误 7000 您的广告已加载

提前致谢

最佳答案

根据文档,您应该首先关闭已加载的广告并请求新广告:

Do not call loadAd on the FBInterstitialAd while the ad is being shown on the screen. If you need to load another FBInterstitialAd for future use, you can do so after the user closed the current one, for example in the interstitialAdDidClose callback.

因此在这种情况下,您需要等到用户关闭第一个广告:

func interstitialAdDidClose(_ interstitialAd: FBInterstitialAd?) {
    print("Interstitial had been closed")
    // Consider to add code here to resume your app's flow

   // .. Schedule the timer, or show another ad .. //

}

请阅读: Adding Interstitial Ad to your iOS app

或者查看这个问题InterstitialAd failed to load with error? :

The error you were receiving is basically we can't match a Facebook profile to deliver relevant ads.

关于ios - 我想在 ios 中每五分钟加载一次 facebook 插页式广告(swift),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53649266/

相关文章:

javascript - 这段JS代码是做什么的?

c# - Facebook Graph API 在用户未登录时获取数据

javascript - 如何检查应用程序是否从 Safari 中的 JS 安装?

iphone - 如何在 iPhone 上制作 "dismiss keyboard"?

ios - NSManagedObject 子类中的重复符号错误

Swift 3 Oauth2 Imgur 刷新键 - 错误 400 "Invalid grant_type parameter or parameter missing"

android - 在圆形 ImageView 中获取用户个人资料图片

iphone - UIAnimation 导致 XCode 在一段时间后崩溃

javascript - 使用 JavaScript 检测 iOS 移动设备而不是自动播放音频

asynchronous - 从异步函数重新加载 UITable 调用