Search code examples
iosswiftgdprconsentform

Swift -GDPR Consent form returns Error: invalid app name


For some reason when I try to load the GDPR Consent form I keep getting the error:

Error: invalid app name.

It happens here :

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
    }

When I do a global search for invalid app name I get brought to the consentform.html file:

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

This tells some value from either the googleservice-plist or my info.plist or something else isn't being read correctly but I don't know which value to look at.

Inside my info.plist I have the GADApplicationIdentifier correctly set:

enter image description here

Why is my app's name coming up as 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
                }
    }

enter image description here


Solution

  • I had to add dig deep to find out the problem but the issue was the CFBundleDisplayName or better yet the Bundle Display Name(red) in the info.plist was blank:

    enter image description here

    If the Bundle Display Name (red) is blank then the GDPR Consent form will return an error. You can either manually type in your app's name

    OR

    just DELETE the entire (red)Bundle Display Name k/v field. If you delete it then then the GDPR Consent will resort to use the Bundle Name(yellow).

    Whatever you do DON'T make the mistake and delete theBundle Name(yellow) .

    Follow these 2 answers for an explanation between the Bundle Display Name and the Bundle Name:

    Bundle Display Name explained

    Bundle Display Name with pics