iOS 전면 광고
2
3
전면 광고 구현
import AdropAds
class ViewController: UIViewController {
private var interstitialAd: AdropInterstitialAd?
override func viewDidLoad() {
super.viewDidLoad()
// 전면 광고 로드
loadInterstitialAd()
// 버튼 클릭 시 광고 표시
setupShowButton()
}
private func loadInterstitialAd() {
interstitialAd = AdropInterstitialAd(unitId: AdropUnitId.INTERSTITIAL_IMAGE)
interstitialAd?.delegate = self
interstitialAd?.load()
}
private func showInterstitialAd() {
if interstitialAd?.isLoaded == true {
interstitialAd?.show(fromRootViewController: self)
} else {
print("광고가 아직 로드되지 않았습니다")
// 광고 재로드
loadInterstitialAd()
}
}
}
extension ViewController: AdropInterstitialAdDelegate {
func onAdReceived(_ ad: AdropInterstitialAd) {
print("전면 광고 로드 성공: \\(ad.unitId)")
}
func onAdFailedToReceive(_ ad: AdropInterstitialAd, _ error: AdropErrorCode) {
print("전면 광고 로드 실패: \\(error)")
}
func onAdDidPresentFullScreen(_ ad: AdropInterstitialAd) {
print("전면 광고 표시됨")
}
func onAdDidDismissFullScreen(_ ad: AdropInterstitialAd) {
print("전면 광고 닫힘")
// 새 광고 미리 로드
loadInterstitialAd()
}
func onAdClicked(_ ad: AdropInterstitialAd) {
print("전면 광고 클릭됨")
}
func onAdImpression(_ ad: AdropInterstitialAd) {
print("전면 광고 노출 확인됨")
}
func onAdFailedToShowFullScreen(_ ad: AdropInterstitialAd, _ error: AdropErrorCode) {
print("전면 광고 표시 실패: \\(error)")
}
}Last updated