ios - AdMob 插页式广告开始时应用崩溃
问题描述
我最近将我的应用程序上传到 App Store,但我发现了一个错误。每次插页式广告 (AdMob) 开始时,我的程序都会崩溃,我不知道为什么。当我从 Xcode 运行程序时,它永远不会崩溃。
import GoogleMobileAds
首先,我当然已经导入了这个。
也将此添加到我的课程中
GADInterstitialDelegate
在 viewDidLoad() 里面我添加了这个:
interstitial = GADInterstitial(adUnitID: "AD-UNIT-ID")
let request = GADRequest()
request.testDevices = [ kGADSimulatorID] //Should this be removed now when the app is on App Store?
interstitial.load(request)
interstitial.delegate = self
再往下,我将此代码添加到我的保存按钮中:
//Advertisement test
if self.interstitial.isReady
{
self.interstitial.present(fromRootViewController: self)
}
else
{
print("Advertisement is not ready!")
self.performSegue(withIdentifier: "History", sender: self)
}
最后我有这个:
//Advertisement will dismiss from the screen
func interstitialDidDismissScreen(_ ad: GADInterstitial)
{
self.performSegue(withIdentifier: "History", sender: self)
}
我该如何解决这个问题?每次我按下那个“保存按钮”时它都会崩溃,屏幕变黑然后轰隆隆,崩溃。
因此,当我从我的 Xcode 项目中运行它之前,它从未崩溃过,但是当我在 TestFlight 和 App Store 中时,它每次都会崩溃!
解决方案
推荐阅读
- java - 如何使用模数来选择通过 Java 中的 100 个循环迭代的 4 个语句?
- javascript - 在 URL 中捕获网页的状态
- google-cloud-sql - Cloud Run 和 Cloud SQL 之间的连接(内部 IP)
- python - 如何检查矩形轮廓内部是否包含数字?(OpenCV - Python)
- neo4j - Neo4J 中的 WHERE 问题,反序列化错误
- python - 如何在消息框中添加枚举或简单计数器
- python - 是否有一个 python 包可以从我的数据中找到最有影响力的组(分类特征)?
- java - 为什么我们需要在创建 java web 时为放入服务器的类实现 Serializable
- swift - 如何快速将相同的随机数分配给 2 个变量?
- python - 如何将字典列表附加到python中的相同列表?