【发布时间】:2020-05-27 03:33:15
【问题描述】:
我正在尝试在出现时显示来自 google AdMob 的插页式广告,但它没有显示并且在控制台中显示“未准备好”。我已经查看了许多其他教程和堆栈溢出页面,但还没有找到答案。谁能帮我?这是我的代码:
struct ContentView: View {
@State var interstitial: GADInterstitial!
var body: some View{
Text("Some Text").onAppear(perform: {
self.interstitial = GADInterstitial(adUnitID: "ca-app-pub-3940256099942544/4411468910")
let req = GADRequest()
self.interstitial.load(req)
if self.interstitial.isReady{
let root = UIApplication.shared.windows.first?.rootViewController
self.interstitial.present(fromRootViewController: root!)
}else {
print("not ready")
}
})
}
}
【问题讨论】:
标签: ios swift admob swiftui interstitial