Skip to content
This repository has been archived by the owner on Oct 21, 2022. It is now read-only.

EU Consent Form iOS Setup Help #40

Open
liamsaul opened this issue Sep 10, 2019 · 0 comments
Open

EU Consent Form iOS Setup Help #40

liamsaul opened this issue Sep 10, 2019 · 0 comments

Comments

@liamsaul
Copy link

liamsaul commented Sep 10, 2019

Hi,

We created an app in Unity using C# and decided to go with Google Admob to show our ads.

We have got all the ads to work successfully (woohoo!), now we just need to set up our EU consent but because we have no experience in Objective-C, and very little experience in X-Code, we're finding this quite difficult!

We're not using mediation, so we just want to use the Google Rendered Consent Form,

Hopefully we can get some help on this.

Do I need to create a new class in Xcode to set this PAC Consent form up, or can I just put it in an existing class file. (For example, we tried putting the code from the documentation https://developers.google.com/admob/ios/eu-consent in the PersonalizedAdConsent.h file in XCode, though we are unsure if this is the right thing to do.)

I'm started learning some Objective-C/XCode to try and get my head around how to implement it, and this is what I came up with if I were to create a new class...

'#import "ViewController.h"'
#import <PersonalizedAdConsent/PersonalizedAdConsent.h>

//I think this line is for testing purposes only :D
PACConsentInformation.sharedInstance.debugGeography = PACDebugGeographyEEA

@interface ViewController ()

@EnD

@implementation ViewController

  • (void)viewDidLoad {
    [super viewDidLoad];

    // Update Consent Status
    [PACConsentInformation.sharedInstance
    requestConsentInfoUpdateForPublisherIdentifiers:@[ @"pub-PUTOURSINHERE" ]
    completionHandler:^(NSError *_Nullable error) {
    if (error) {
    // Consent info update failed.
    } else {
    // Consent info update succeeded. The shared PACConsentInformation
    // instance has been updated.
    }
    }];

    // Collect Consent
    // TODO: Replace with your app's privacy policy url.
    NSURL *privacyURL = [NSURL URLWithString:@"https://www.your.com/privacyurl"];
    PACConsentForm *form = [[PACConsentForm alloc] initWithApplicationPrivacyPolicyURL:privacyURL];
    form.shouldOfferPersonalizedAds = YES;
    form.shouldOfferNonPersonalizedAds = YES;
    form.shouldOfferAdFree = NO;

    // Load Consent Form
    [form loadWithCompletionHandler:^(NSError *_Nullable error) {
    NSLog(@"Load complete. Error: %@", error);
    if (error) {
    // Handle error.
    } else {
    // Load successful.

      // Show Consent Form
      [form presentFromViewController:self
      dismissCompletion:^(NSError *_Nullable error, BOOL userPrefersAdFree) {
      if (error) {
          // Handle error.
      } else if (userPrefersAdFree) {
          // The user prefers to use a paid version of the app.
      } else {
          // Check the user's consent choice.
          PACConsentStatus status =
              PACConsentInformation.sharedInstance.consentStatus;
      }
      }];        
    

    }
    }];

}

@EnD

Any help would be greatly appreciated, thank you!

[EDIT: FOR SOME REASON I CAN'T GET THE CODE PASTER THING TO FORMAT PROPERLY SO HERE IS AN IMAGE, ALSO THIS IS IN VSCODE BECAUSE IM JUST MESSING AROUND WITH LEARNING IT ON MY PC BEFORE GOING ONTO THE MAC AND TRYING IT]

GitHoob

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant