我无法使用我的代码加载Google AdMob gdpr同意书

问题描述

我已按照Google的说明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;
    

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)