0

我已按照谷歌说明https://developers.google.com/admob/ios/eu-consent#objective-c关于如何实现它并想出了这段代码:我使用的是 Xcode 11.5 版并且没有错误代码表单只是不显示。

#import "boogagoogleform.h"
#import <PersonalizedAdConsent/PersonalizedAdConsent.h>

@interface boogagoogleform ()

@end

@implementation boogagoogleform

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // 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 = FALSE;
    [form loadWithCompletionHandler:^(NSError *_Nullable error) {
      NSLog(@"Load complete. Error: %@", error);
      if (error) {
        // Handle error.
      } else {
        // Load successful.
      }
    }];
    [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;
          }
        }];
    [PACConsentInformation.sharedInstance
        requestConsentInfoUpdateForPublisherIdentifiers:@[ @"pub-012345678" ]
            completionHandler:^(NSError *_Nullable error) {
              if (error) {
                // Consent info update failed.
              } else {
                // Consent info update succeeded. The shared PACConsentInformation
                // instance has been updated.
              }
            }];

    PACConsentInformation.sharedInstance.consentStatus = PACConsentStatusPersonalized;
    

4

0 回答 0