添加 Google 移动插页式广告 Swift
Adding Google Mobile Interstitial Ads Swift
我想添加 Google 移动插页式广告,但出现错误。如何添加 Google 插页式广告?
这是我目前的情况:
var interstitial: GADInterstitial!
func createAndLoadAd() -> GADInterstitial
{
var ad = GADInterstitial()
ad.adUnitID = "ca-app-pub-5378899862041789/8532100959"
var request = GADRequest()
ad.loadRequest(request)
return ad
}
插页式代码:
导入 GoogleMobileAds
框架并设置代理以查看:
import GoogleMobileAds
class ViewController: UIViewController, GADInterstitialDelegate
声明:
var interstitial:GADInterstitial?
函数:
//Interstitial func
func createAndLoadInterstitial()->GADInterstitial {
var interstitial = GADInterstitial(adUnitID: "ca-app-pub-5378899862041789/8532100959")
interstitial.delegate = self
interstitial.loadRequest(GADRequest())
return interstitial
}
函数调用:
interstitial = createAndLoadInterstitial()
添加委托方法来加载广告。
添加SDK需要的其他框架
SDK 依赖于以下 iOS 开发框架,它们可能尚未成为您项目的一部分:
AdSupport
AudioToolbox
AVFoundation
CoreGraphics
CoreMedia
CoreTelephony
EventKit
EventKitUI
MessageUI
StoreKit
SystemConfiguration
对于更新的选项,请按照 Google 提供的步骤进行操作。
我想添加 Google 移动插页式广告,但出现错误。如何添加 Google 插页式广告?
这是我目前的情况:
var interstitial: GADInterstitial!
func createAndLoadAd() -> GADInterstitial
{
var ad = GADInterstitial()
ad.adUnitID = "ca-app-pub-5378899862041789/8532100959"
var request = GADRequest()
ad.loadRequest(request)
return ad
}
插页式代码:
导入 GoogleMobileAds
框架并设置代理以查看:
import GoogleMobileAds
class ViewController: UIViewController, GADInterstitialDelegate
声明:
var interstitial:GADInterstitial?
函数:
//Interstitial func
func createAndLoadInterstitial()->GADInterstitial {
var interstitial = GADInterstitial(adUnitID: "ca-app-pub-5378899862041789/8532100959")
interstitial.delegate = self
interstitial.loadRequest(GADRequest())
return interstitial
}
函数调用:
interstitial = createAndLoadInterstitial()
添加委托方法来加载广告。
添加SDK需要的其他框架
SDK 依赖于以下 iOS 开发框架,它们可能尚未成为您项目的一部分:
AdSupport
AudioToolbox
AVFoundation
CoreGraphics
CoreMedia
CoreTelephony
EventKit
EventKitUI
MessageUI
StoreKit
SystemConfiguration
对于更新的选项,请按照 Google 提供的步骤进行操作。