首页 > 解决方案 > Admob GDPR 同意对话框每次返回欧盟时都会弹出?

问题描述

我在 Admob 同意对话框中遇到了奇怪的行为,每次我在国外几天后返回英国时,GPDR admob 对话框再次弹出,我必须再次同意。

下面是我正在使用的代码:

   // PACConsentInformation.sharedInstance.debugGeography   = .EEA;
    PACConsentInformation.sharedInstance.requestConsentInfoUpdate( forPublisherIdentifiers: ["pub-XXXXX"])
    {(_ error: Error?) -> Void in

        if let error = error
        {
            print("[GDPR][CHECK] Error updateing \(error)")
        } else
        {
            print("[GDPR][CHECK] Updated")

            let status =  PACConsentInformation.sharedInstance.consentStatus

            if status == PACConsentStatus.personalized
            {
                print("[GDPR][CHECK] User selected personalized")
                user_info().set(key: user.gdpr_nonPersonalized, value: false)
            }else
            if status == PACConsentStatus.nonPersonalized
            {
                print("[GDPR][CHECK] User selected none-personalized")
                user_info().set(key: user.gdpr_nonPersonalized, value: true)
            }else
            //unknown !!
            if status == PACConsentStatus.unknown && PACConsentInformation.sharedInstance.isRequestLocationInEEAOrUnknown == true
            {
                print("[GDPR][CHECK] unkown !")
                APP_DELEGATE.showGDPRDialog(from: self)
            }else
            {
               print("[GDPR][CHECK] unkown ! user outside EU" )
               user_info().set(key: user.gdpr_nonPersonalized, value: false)
            }
        }
    }


//[GDPR] Dialog
    func showGDPRDialog( from:UIViewController)
    {

        guard let privacyUrl = URL(string: "http://xx/privacy-policy"),
            let form = PACConsentForm(applicationPrivacyPolicyURL: privacyUrl) else {
                print("[GDPR] incorrect privacy URL.")
                return
        }

        form.shouldOfferPersonalizedAds    = true
        form.shouldOfferNonPersonalizedAds = true
        form.shouldOfferAdFree             = false

        form.load {(_ error: Error?) -> Void in

            print("[GDPR] FORM Load complete.")

            if let error = error {
                // Handle error.
                print("[GDPR] FORM Error loading form: \(error.localizedDescription)")
            } else
            {
                print("[GDPR] success will present.")

                // Load successful.
                user_info().set(key: user.gdpr_dialog_showed, value: true)

                form.present(from: from) { (error, userPrefersAdFree) in

                    APP_DELEGATE.logEvent("opened_gdpr", [ : ]);

                    if let error = error
                    {
                        // Handle error.
                        print("[GDPR] ERROR while present \(error)")
                    } else if userPrefersAdFree
                    {
                        // User prefers to use a paid version of the app.
                    } else
                    {

                        ALPrivacySettings.setHasUserConsent(true)

                        // Check the user's consent choice.
                        let status =  PACConsentInformation.sharedInstance.consentStatus

                        if status == PACConsentStatus.personalized
                        {

                            print("[GDPR] User selected personalized")
                            user_info().set(key: user.gdpr_nonPersonalized, value: false)
                            PACConsentInformation.sharedInstance.consentStatus = .personalized
                        }else
                        if status == PACConsentStatus.nonPersonalized
                        {

                            print("[GDPR] User selected none-personalized")
                            user_info().set(key: user.gdpr_nonPersonalized, value: true)
                            PACConsentInformation.sharedInstance.consentStatus = .nonPersonalized
                        }else
                        {

                        }

                    }
                }
            }
        }
    }

这是正常的吗?什么是 GDPR 同意对话框的展示!

标签: iosswiftadmob

解决方案


仅在以下情况为真时显示同意书

requestLocationInEEAOrUnknown

推荐阅读