INNER CODE UNIT · Swift

loadInterstantialAd

kmcgill88/admob_flutter · ios/Classes/AdmobInterstitialPlugin.swift:81

    private func loadInterstantialAd(id: Int, interstantialAdUnitId: String, nonPersonalizedAds: Bool) {
        let interstantial = getInterstitialAd(id: id, interstantialAdUnitId: interstantialAdUnitId)
        let request = GADRequest()

        if (nonPersonalizedAds) {
            let extras = GADExtras()
            extras.additionalParameters = ["npa": "1"]
            request.register(extras)
        }

        interstantial.load(request)
    }
    
    private func getInterstitialAd(id: Int, interstantialAdUnitId: String) -> GADInterstitial {
        if let interstantialAd = allIds[id] {
            // https://developers.google.com/admob/ios/interstitial#use_gadinterstitialdelegate_to_reload
            // "GADInterstitial is a one-time-use object. This means once an interstitial is shown, hasBeenUsed returns true and the interstitial can't be used to load another ad. To request another interstitial, you'll need to create a new GADInterstitial object."
            if (interstantialAd.hasBeenUsed) {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…