【问题标题】:Swift -GDPR Consent form returns Error: invalid app nameSwift -GDPR 同意书返回错误:应用名称无效
【发布时间】:2020-12-05 18:22:55
【问题描述】:

由于某种原因,当我尝试加载 GDPR 同意书时,我不断收到错误消息:

错误:应用名称无效。

它发生在这里:

form.load { [weak self](_ error: Error?) -> Void in
                    print("Load complete.")

    if let error = error {

        // *** HERE IS THE ERROR ***

        print("Error loading form: \(error.localizedDescription)")
        return
    }

当我对invalid app name 进行全局搜索时,我会被带到consentform.html 文件:

// Set app name.
var appName = formInfo['app_name'] || '';
if (appName.length <= 0) {
  formLoadCompleted('Error: invalid app name.');
}

这告诉了googleservice-plist 或我的info.plist 的一些值,或者其他没有被正确读取的值,但我不知道要查看哪个值。

在我的info.plist 中,我正确设置了GADApplicationIdentifier

为什么我的应用名称显示为 nil?

PACConsentInformation.sharedInstance.debugGeography = .EEA

    PACConsentInformation
        .sharedInstance
        .requestConsentInfoUpdate(forPublisherIdentifiers: ["pub-MY_PublisherID"]) { [weak self](error) in

            if let error = error { return }
            PACConsentInformation.sharedInstance.isRequestLocationInEEAOrUnknown {

                if PACConsentInformation.sharedInstance.consentStatus == PACConsentStatus.unknown {

                    guard let privacyUrl = URL(string: "My_Privacy_URL"),
                        let form = PACConsentForm(applicationPrivacyPolicyURL: privacyUrl) else {
                            return
                    }
                    form.shouldOfferPersonalizedAds = true
                    form.shouldOfferNonPersonalizedAds = true
                    form.shouldOfferAdFree = true

                    form.load { [weak self](_ error: Error?) -> Void in
                        print("Load complete.")

                        if let error = error {

                            // *** HERE IS THE ERROR ***

                            print("Error loading form: \(error.localizedDescription)")
                            return
                        }

                        // ...
                    }

                    return
                }
    }

【问题讨论】:

    标签: ios swift gdprconsentform


    【解决方案1】:

    我必须深入挖掘才能找出问题,但问题是 CFBundleDisplayName 或更好,但 info.plist 中的 Bundle Display Name(red) 是空白的:

    如果Bundle Display Name(红色)为空白,则GDPR Consent 表单将返回错误。您可以手动输入应用名称

    只需删除整个(红色)Bundle Display Name k/v 字段。如果您删除它,那么GDPR Consent 将使用Bundle Name(黄色)。

    无论您做什么,都不要犯错并删除Bundle Name(黄色)。

    请按照以下 2 个答案了解 Bundle Display NameBundle Name 之间的解释:

    Bundle Display Name explained

    Bundle Display Name with pics

    【讨论】:

    • Admob 确实有奇怪的行为!我的应用名称在 Springboard 上显示得很好,但我也遇到了这个错误。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多