gpt4 book ai didi

ios - SWIFT ADMOB : Failed to load: Request Error: No ad to show

转载 作者:行者123 更新时间:2023-11-30 12:03:25 29 4
gpt4 key购买 nike

我实际上正在 Swift 中使用 AdMob Reward 开发 iOS 应用程序,当我尝试使用模拟器(iPhone 6、6s、7、8...等)构建我的应用程序时,广告可以正常工作,而且我也有此消息:

Reward based video ad is received.

但是(因为总是有一个但是)当我在自己的设备(iPhone 6)上构建我的应用程序时,它不起作用,并且出现以下错误消息:“基于奖励的视频广告加载失败:请求错误:没有可展示的广告。”这是我的代码(显然,我通过“奖励广告 Mob 入门”中给出的示例更改了广告 ID,但在我的应用程序中,我使用我的广告 ID)。这是我为示例选择的示例 ID:ca-app-pub-3940256099942544/1712485313

let request = GADRequest()
request.testDevices = [ kGADSimulatorID,"ca-app-pub-3940256099942544/1712485313"];
rewardBasedVideo = GADRewardBasedVideoAd.sharedInstance()
rewardBasedVideo?.delegate = self
if rewardBasedVideo?.isReady == false {
rewardBasedVideo?.load(GADRequest(), withAdUnitID: "ca-app-pub-3940256099942544/1712485313")
adRequestInProgress = true
}

还有

//ADMOB
// MARK: GADRewardBasedVideoAdDelegate implementation
func rewardBasedVideoAd(_ rewardBasedVideoAd: GADRewardBasedVideoAd,
didFailToLoadWithError error: Error) {
adRequestInProgress = false
print("Reward based video ad failed to load: \(error.localizedDescription)")
}

func rewardBasedVideoAdDidReceive(_ rewardBasedVideoAd: GADRewardBasedVideoAd) {
adRequestInProgress = false
print("Reward based video ad is received.")
}

func rewardBasedVideoAdDidOpen(_ rewardBasedVideoAd: GADRewardBasedVideoAd) {
print("Opened reward based video ad.")
}

func rewardBasedVideoAdDidStartPlaying(_ rewardBasedVideoAd: GADRewardBasedVideoAd) {
print("Reward based video ad started playing.")
}

func rewardBasedVideoAdDidClose(_ rewardBasedVideoAd: GADRewardBasedVideoAd) {
print("Reward based video ad is closed.")
}

func rewardBasedVideoAdWillLeaveApplication(_ rewardBasedVideoAd: GADRewardBasedVideoAd) {
print("Reward based video ad will leave application.")
}

func rewardBasedVideoAd(_ rewardBasedVideoAd: GADRewardBasedVideoAd,
didRewardUserWith reward: GADAdReward) {
print("Reward received with currency: \(reward.type), amount \(reward.amount).")
}
//ADMOB!

最佳答案

首先,您应该查看日志以获取真实设备的标识符

然后修复该行:

request.testDevices = [...]

将...替换为模拟器和真实设备的 if然后您就可以看到测试广告您使用了广告单元 ID,而不是设备 ID

关于ios - SWIFT ADMOB : Failed to load: Request Error: No ad to show,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46934940/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com