我最近将我的应用程序上传到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中运行时,它每次都会崩溃!