From 7a47b72b05604d3264756676502c8c345386e937 Mon Sep 17 00:00:00 2001 From: Jill Song Date: Wed, 4 Sep 2024 14:56:19 -0700 Subject: [PATCH] Add Ad Inspector support. PiperOrigin-RevId: 671110526 --- .../Base.lproj/Main.storyboard | 10 +++++-- .../MainViewController.h | 2 ++ .../MainViewController.m | 25 +++++++++++++++++- .../Base.lproj/Main.storyboard | 10 +++++-- .../AdManagerBannerExample/ViewController.m | 24 +++++++++++++++++ .../Base.lproj/Main.storyboard | 10 +++++-- .../ViewController.h | 3 +++ .../ViewController.m | 23 ++++++++++++++++ .../Base.lproj/Main.storyboard | 10 +++++-- .../ViewController.h | 3 +++ .../ViewController.m | 23 ++++++++++++++++ .../Base.lproj/Main.storyboard | 10 +++++-- .../ViewController.m | 26 +++++++++++++++++++ .../Base.lproj/Main.storyboard | 10 +++++-- .../ViewController.m | 26 +++++++++++++++++++ .../AppOpenExample/Base.lproj/Main.storyboard | 10 +++++-- .../AppOpenExample/MainViewController.h | 2 ++ .../AppOpenExample/MainViewController.m | 25 +++++++++++++++++- .../BannerExample/Base.lproj/Main.storyboard | 10 +++++-- .../BannerExample/ViewController.m | 24 +++++++++++++++++ .../Base.lproj/Main.storyboard | 8 +++++- .../MainViewController.m | 24 +++++++++++++++++ .../Base.lproj/Main.storyboard | 10 +++++-- .../InterstitialExample/ViewController.h | 3 +++ .../InterstitialExample/ViewController.m | 23 ++++++++++++++++ .../Base.lproj/Main.storyboard | 10 +++++-- .../NativeAdvancedExample/ViewController.h | 3 +++ .../NativeAdvancedExample/ViewController.m | 23 ++++++++++++++++ .../Base.lproj/Main.storyboard | 10 +++++-- .../ViewController.m | 26 +++++++++++++++++++ .../Base.lproj/Main.storyboard | 10 +++++-- .../RewardedVideoExample/ViewController.m | 26 +++++++++++++++++++ 32 files changed, 435 insertions(+), 27 deletions(-) diff --git a/Objective-C/admanager/AdManagerAppOpenExample/AdManagerAppOpenExample/Base.lproj/Main.storyboard b/Objective-C/admanager/AdManagerAppOpenExample/AdManagerAppOpenExample/Base.lproj/Main.storyboard index 1cd80f61..027f8389 100644 --- a/Objective-C/admanager/AdManagerAppOpenExample/AdManagerAppOpenExample/Base.lproj/Main.storyboard +++ b/Objective-C/admanager/AdManagerAppOpenExample/AdManagerAppOpenExample/Base.lproj/Main.storyboard @@ -1,9 +1,9 @@ - + - + @@ -104,6 +104,11 @@ + + + + + @@ -111,6 +116,7 @@ + diff --git a/Objective-C/admanager/AdManagerAppOpenExample/AdManagerAppOpenExample/MainViewController.h b/Objective-C/admanager/AdManagerAppOpenExample/AdManagerAppOpenExample/MainViewController.h index 958a41c8..9400fc1c 100644 --- a/Objective-C/admanager/AdManagerAppOpenExample/AdManagerAppOpenExample/MainViewController.h +++ b/Objective-C/admanager/AdManagerAppOpenExample/AdManagerAppOpenExample/MainViewController.h @@ -20,4 +20,6 @@ @property(weak, nonatomic) IBOutlet UIBarButtonItem *privacySettingsButton; +@property(weak, nonatomic) IBOutlet UIBarButtonItem *adInspectorButton; + @end diff --git a/Objective-C/admanager/AdManagerAppOpenExample/AdManagerAppOpenExample/MainViewController.m b/Objective-C/admanager/AdManagerAppOpenExample/AdManagerAppOpenExample/MainViewController.m index c756138d..207b0a00 100644 --- a/Objective-C/admanager/AdManagerAppOpenExample/AdManagerAppOpenExample/MainViewController.m +++ b/Objective-C/admanager/AdManagerAppOpenExample/AdManagerAppOpenExample/MainViewController.m @@ -15,7 +15,7 @@ // #import "MainViewController.h" - +#import #import "GoogleMobileAdsConsentManager.h" @interface MainViewController () @@ -53,4 +53,27 @@ - (IBAction)privacySettingsTapped:(UIBarButtonItem *)sender { }]; } +- (IBAction)adInspectorTapped:(UIBarButtonItem *)sender { + [GADMobileAds.sharedInstance + presentAdInspectorFromViewController:self + completionHandler:^(NSError *_Nullable error) { + if (error) { + UIAlertController *alertController = [UIAlertController + alertControllerWithTitle:error.localizedDescription + message:@"Please try again later." + preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *defaultAction = + [UIAlertAction actionWithTitle:@"OK" + style:UIAlertActionStyleCancel + handler:^(UIAlertAction *action){ + }]; + + [alertController addAction:defaultAction]; + [self presentViewController:alertController + animated:YES + completion:nil]; + } + }]; +} + @end diff --git a/Objective-C/admanager/AdManagerBannerExample/AdManagerBannerExample/Base.lproj/Main.storyboard b/Objective-C/admanager/AdManagerBannerExample/AdManagerBannerExample/Base.lproj/Main.storyboard index f6066df5..c97c4796 100644 --- a/Objective-C/admanager/AdManagerBannerExample/AdManagerBannerExample/Base.lproj/Main.storyboard +++ b/Objective-C/admanager/AdManagerBannerExample/AdManagerBannerExample/Base.lproj/Main.storyboard @@ -1,9 +1,9 @@ - + - + @@ -56,6 +56,11 @@ + + + + + @@ -64,6 +69,7 @@ + diff --git a/Objective-C/admanager/AdManagerBannerExample/AdManagerBannerExample/ViewController.m b/Objective-C/admanager/AdManagerBannerExample/AdManagerBannerExample/ViewController.m index 605da0cd..2073c234 100644 --- a/Objective-C/admanager/AdManagerBannerExample/AdManagerBannerExample/ViewController.m +++ b/Objective-C/admanager/AdManagerBannerExample/AdManagerBannerExample/ViewController.m @@ -23,6 +23,7 @@ @interface ViewController () @property(nonatomic, weak) IBOutlet GAMBannerView *bannerView; @property(weak, nonatomic) IBOutlet UIBarButtonItem *privacySettingsButton; +@property(weak, nonatomic) IBOutlet UIBarButtonItem *adInspectorButton; @end @@ -51,6 +52,29 @@ - (IBAction)privacySettingsTapped:(UIBarButtonItem *)sender { }]; } +- (IBAction)adInspectorTapped:(UIBarButtonItem *)sender { + [GADMobileAds.sharedInstance + presentAdInspectorFromViewController:self + completionHandler:^(NSError *_Nullable error) { + if (error) { + UIAlertController *alertController = [UIAlertController + alertControllerWithTitle:error.localizedDescription + message:@"Please try again later." + preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *defaultAction = + [UIAlertAction actionWithTitle:@"OK" + style:UIAlertActionStyleCancel + handler:^(UIAlertAction *action){ + }]; + + [alertController addAction:defaultAction]; + [self presentViewController:alertController + animated:YES + completion:nil]; + } + }]; +} + - (void)viewDidLoad { [super viewDidLoad]; diff --git a/Objective-C/admanager/AdManagerCustomRenderingExample/AdManagerCustomRenderingExample/Base.lproj/Main.storyboard b/Objective-C/admanager/AdManagerCustomRenderingExample/AdManagerCustomRenderingExample/Base.lproj/Main.storyboard index b69b8c9f..2e543b48 100644 --- a/Objective-C/admanager/AdManagerCustomRenderingExample/AdManagerCustomRenderingExample/Base.lproj/Main.storyboard +++ b/Objective-C/admanager/AdManagerCustomRenderingExample/AdManagerCustomRenderingExample/Base.lproj/Main.storyboard @@ -1,9 +1,9 @@ - + - + @@ -174,6 +174,11 @@ + + + + + @@ -181,6 +186,7 @@ + diff --git a/Objective-C/admanager/AdManagerCustomRenderingExample/AdManagerCustomRenderingExample/ViewController.h b/Objective-C/admanager/AdManagerCustomRenderingExample/AdManagerCustomRenderingExample/ViewController.h index b44e6379..77edb68d 100644 --- a/Objective-C/admanager/AdManagerCustomRenderingExample/AdManagerCustomRenderingExample/ViewController.h +++ b/Objective-C/admanager/AdManagerCustomRenderingExample/AdManagerCustomRenderingExample/ViewController.h @@ -21,6 +21,9 @@ /// The privacy settings button. @property(weak, nonatomic) IBOutlet UIBarButtonItem *privacySettingsButton; +/// The ad inspector button. +@property(weak, nonatomic) IBOutlet UIBarButtonItem *adInspectorButton; + /// Container that holds the native ad. @property(nonatomic, weak) IBOutlet UIView *nativeAdPlaceholder; diff --git a/Objective-C/admanager/AdManagerCustomRenderingExample/AdManagerCustomRenderingExample/ViewController.m b/Objective-C/admanager/AdManagerCustomRenderingExample/AdManagerCustomRenderingExample/ViewController.m index 3487c5c8..7b616d19 100644 --- a/Objective-C/admanager/AdManagerCustomRenderingExample/AdManagerCustomRenderingExample/ViewController.m +++ b/Objective-C/admanager/AdManagerCustomRenderingExample/AdManagerCustomRenderingExample/ViewController.m @@ -111,6 +111,29 @@ - (IBAction)privacySettingsTapped:(UIBarButtonItem *)sender { }]; } +- (IBAction)adInspectorTapped:(UIBarButtonItem *)sender { + [GADMobileAds.sharedInstance + presentAdInspectorFromViewController:self + completionHandler:^(NSError *_Nullable error) { + if (error) { + UIAlertController *alertController = [UIAlertController + alertControllerWithTitle:error.localizedDescription + message:@"Please try again later." + preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *defaultAction = + [UIAlertAction actionWithTitle:@"OK" + style:UIAlertActionStyleCancel + handler:^(UIAlertAction *action){ + }]; + + [alertController addAction:defaultAction]; + [self presentViewController:alertController + animated:YES + completion:nil]; + } + }]; +} + - (IBAction)refreshAd:(id)sender { // Loads an ad for native ads or custom native ads. NSMutableArray *adTypes = [[NSMutableArray alloc] init]; diff --git a/Objective-C/admanager/AdManagerInterstitialExample/AdManagerInterstitialExample/Base.lproj/Main.storyboard b/Objective-C/admanager/AdManagerInterstitialExample/AdManagerInterstitialExample/Base.lproj/Main.storyboard index c850a6f3..59ab3b25 100644 --- a/Objective-C/admanager/AdManagerInterstitialExample/AdManagerInterstitialExample/Base.lproj/Main.storyboard +++ b/Objective-C/admanager/AdManagerInterstitialExample/AdManagerInterstitialExample/Base.lproj/Main.storyboard @@ -1,9 +1,9 @@ - + - + @@ -86,6 +86,11 @@ + + + + + @@ -93,6 +98,7 @@ + diff --git a/Objective-C/admanager/AdManagerInterstitialExample/AdManagerInterstitialExample/ViewController.h b/Objective-C/admanager/AdManagerInterstitialExample/AdManagerInterstitialExample/ViewController.h index c915b91b..de6b580b 100644 --- a/Objective-C/admanager/AdManagerInterstitialExample/AdManagerInterstitialExample/ViewController.h +++ b/Objective-C/admanager/AdManagerInterstitialExample/AdManagerInterstitialExample/ViewController.h @@ -27,6 +27,9 @@ /// The privacy settings button. @property(nonatomic, weak) IBOutlet UIBarButtonItem *privacySettingsButton; +/// The ad inspector button. +@property(weak, nonatomic) IBOutlet UIBarButtonItem *adInspectorButton; + /// The game text. @property(nonatomic, weak) IBOutlet UILabel *gameText; diff --git a/Objective-C/admanager/AdManagerInterstitialExample/AdManagerInterstitialExample/ViewController.m b/Objective-C/admanager/AdManagerInterstitialExample/AdManagerInterstitialExample/ViewController.m index a74ba5d1..695b4fa4 100644 --- a/Objective-C/admanager/AdManagerInterstitialExample/AdManagerInterstitialExample/ViewController.m +++ b/Objective-C/admanager/AdManagerInterstitialExample/AdManagerInterstitialExample/ViewController.m @@ -255,6 +255,29 @@ - (IBAction)privacySettingsTapped:(UIBarButtonItem *)sender { }]; } +- (IBAction)adInspectorTapped:(UIBarButtonItem *)sender { + [GADMobileAds.sharedInstance + presentAdInspectorFromViewController:self + completionHandler:^(NSError *_Nullable error) { + if (error) { + UIAlertController *alertController = [UIAlertController + alertControllerWithTitle:error.localizedDescription + message:@"Please try again later." + preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *defaultAction = + [UIAlertAction actionWithTitle:@"OK" + style:UIAlertActionStyleCancel + handler:^(UIAlertAction *action){ + }]; + + [alertController addAction:defaultAction]; + [self presentViewController:alertController + animated:YES + completion:nil]; + } + }]; +} + - (IBAction)playAgain:(id)sender { [self startNewGame]; diff --git a/Objective-C/admanager/AdManagerRewardedInterstitialExample/AdManagerRewardedInterstitialExample/Base.lproj/Main.storyboard b/Objective-C/admanager/AdManagerRewardedInterstitialExample/AdManagerRewardedInterstitialExample/Base.lproj/Main.storyboard index 7cbea2ca..278e3fd5 100644 --- a/Objective-C/admanager/AdManagerRewardedInterstitialExample/AdManagerRewardedInterstitialExample/Base.lproj/Main.storyboard +++ b/Objective-C/admanager/AdManagerRewardedInterstitialExample/AdManagerRewardedInterstitialExample/Base.lproj/Main.storyboard @@ -1,9 +1,9 @@ - + - + @@ -76,6 +76,11 @@ + + + + + @@ -83,6 +88,7 @@ + diff --git a/Objective-C/admanager/AdManagerRewardedInterstitialExample/AdManagerRewardedInterstitialExample/ViewController.m b/Objective-C/admanager/AdManagerRewardedInterstitialExample/AdManagerRewardedInterstitialExample/ViewController.m index bac694ea..3fc7702f 100644 --- a/Objective-C/admanager/AdManagerRewardedInterstitialExample/AdManagerRewardedInterstitialExample/ViewController.m +++ b/Objective-C/admanager/AdManagerRewardedInterstitialExample/AdManagerRewardedInterstitialExample/ViewController.m @@ -43,6 +43,9 @@ @interface ViewController () /// The privacy settings button. @property(weak, nonatomic) IBOutlet UIBarButtonItem *privacySettingsButton; +/// The ad inspector button. +@property(weak, nonatomic) IBOutlet UIBarButtonItem *adInspectorButton; + /// The game text. @property(nonatomic, weak) IBOutlet UILabel *gameText; @@ -317,6 +320,29 @@ - (IBAction)privacySettingsTapped:(UIBarButtonItem *)sender { }]; } +- (IBAction)adInspectorTapped:(UIBarButtonItem *)sender { + [GADMobileAds.sharedInstance + presentAdInspectorFromViewController:self + completionHandler:^(NSError *_Nullable error) { + if (error) { + UIAlertController *alertController = [UIAlertController + alertControllerWithTitle:error.localizedDescription + message:@"Please try again later." + preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *defaultAction = + [UIAlertAction actionWithTitle:@"OK" + style:UIAlertActionStyleCancel + handler:^(UIAlertAction *action){ + }]; + + [alertController addAction:defaultAction]; + [self presentViewController:alertController + animated:YES + completion:nil]; + } + }]; +} + - (IBAction)playAgain:(id)sender { [self startNewGame]; if (GoogleMobileAdsConsentManager.sharedInstance.canRequestAds) { diff --git a/Objective-C/admanager/AdManagerRewardedVideoExample/AdManagerRewardedVideoExample/Base.lproj/Main.storyboard b/Objective-C/admanager/AdManagerRewardedVideoExample/AdManagerRewardedVideoExample/Base.lproj/Main.storyboard index 8bae046c..f1db3489 100644 --- a/Objective-C/admanager/AdManagerRewardedVideoExample/AdManagerRewardedVideoExample/Base.lproj/Main.storyboard +++ b/Objective-C/admanager/AdManagerRewardedVideoExample/AdManagerRewardedVideoExample/Base.lproj/Main.storyboard @@ -1,9 +1,9 @@ - + - + @@ -87,6 +87,11 @@ + + + + + @@ -94,6 +99,7 @@ + diff --git a/Objective-C/admanager/AdManagerRewardedVideoExample/AdManagerRewardedVideoExample/ViewController.m b/Objective-C/admanager/AdManagerRewardedVideoExample/AdManagerRewardedVideoExample/ViewController.m index e4969101..182b1bc9 100644 --- a/Objective-C/admanager/AdManagerRewardedVideoExample/AdManagerRewardedVideoExample/ViewController.m +++ b/Objective-C/admanager/AdManagerRewardedVideoExample/AdManagerRewardedVideoExample/ViewController.m @@ -38,6 +38,9 @@ @interface ViewController () /// The privacy settings button. @property(weak, nonatomic) IBOutlet UIBarButtonItem *privacySettingsButton; +/// The ad inspector button. +@property(weak, nonatomic) IBOutlet UIBarButtonItem *adInspectorButton; + /// The game text. @property(weak, nonatomic) IBOutlet UILabel *gameLabel; @@ -259,6 +262,29 @@ - (IBAction)privacySettingsTapped:(UIBarButtonItem *)sender { }]; } +- (IBAction)adInspectorTapped:(UIBarButtonItem *)sender { + [GADMobileAds.sharedInstance + presentAdInspectorFromViewController:self + completionHandler:^(NSError *_Nullable error) { + if (error) { + UIAlertController *alertController = [UIAlertController + alertControllerWithTitle:error.localizedDescription + message:@"Please try again later." + preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *defaultAction = + [UIAlertAction actionWithTitle:@"OK" + style:UIAlertActionStyleCancel + handler:^(UIAlertAction *action){ + }]; + + [alertController addAction:defaultAction]; + [self presentViewController:alertController + animated:YES + completion:nil]; + } + }]; +} + - (IBAction)playAgain:(id)sender { [self startNewGame]; if (GoogleMobileAdsConsentManager.sharedInstance.canRequestAds) { diff --git a/Objective-C/admob/AppOpenExample/AppOpenExample/Base.lproj/Main.storyboard b/Objective-C/admob/AppOpenExample/AppOpenExample/Base.lproj/Main.storyboard index 0f5d35f3..416eb392 100644 --- a/Objective-C/admob/AppOpenExample/AppOpenExample/Base.lproj/Main.storyboard +++ b/Objective-C/admob/AppOpenExample/AppOpenExample/Base.lproj/Main.storyboard @@ -1,9 +1,9 @@ - + - + @@ -104,6 +104,11 @@ + + + + + @@ -111,6 +116,7 @@ + diff --git a/Objective-C/admob/AppOpenExample/AppOpenExample/MainViewController.h b/Objective-C/admob/AppOpenExample/AppOpenExample/MainViewController.h index 958a41c8..9400fc1c 100644 --- a/Objective-C/admob/AppOpenExample/AppOpenExample/MainViewController.h +++ b/Objective-C/admob/AppOpenExample/AppOpenExample/MainViewController.h @@ -20,4 +20,6 @@ @property(weak, nonatomic) IBOutlet UIBarButtonItem *privacySettingsButton; +@property(weak, nonatomic) IBOutlet UIBarButtonItem *adInspectorButton; + @end diff --git a/Objective-C/admob/AppOpenExample/AppOpenExample/MainViewController.m b/Objective-C/admob/AppOpenExample/AppOpenExample/MainViewController.m index c756138d..207b0a00 100644 --- a/Objective-C/admob/AppOpenExample/AppOpenExample/MainViewController.m +++ b/Objective-C/admob/AppOpenExample/AppOpenExample/MainViewController.m @@ -15,7 +15,7 @@ // #import "MainViewController.h" - +#import #import "GoogleMobileAdsConsentManager.h" @interface MainViewController () @@ -53,4 +53,27 @@ - (IBAction)privacySettingsTapped:(UIBarButtonItem *)sender { }]; } +- (IBAction)adInspectorTapped:(UIBarButtonItem *)sender { + [GADMobileAds.sharedInstance + presentAdInspectorFromViewController:self + completionHandler:^(NSError *_Nullable error) { + if (error) { + UIAlertController *alertController = [UIAlertController + alertControllerWithTitle:error.localizedDescription + message:@"Please try again later." + preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *defaultAction = + [UIAlertAction actionWithTitle:@"OK" + style:UIAlertActionStyleCancel + handler:^(UIAlertAction *action){ + }]; + + [alertController addAction:defaultAction]; + [self presentViewController:alertController + animated:YES + completion:nil]; + } + }]; +} + @end diff --git a/Objective-C/admob/BannerExample/BannerExample/Base.lproj/Main.storyboard b/Objective-C/admob/BannerExample/BannerExample/Base.lproj/Main.storyboard index 9cae367a..18f20145 100644 --- a/Objective-C/admob/BannerExample/BannerExample/Base.lproj/Main.storyboard +++ b/Objective-C/admob/BannerExample/BannerExample/Base.lproj/Main.storyboard @@ -1,9 +1,9 @@ - + - + @@ -56,6 +56,11 @@ + + + + + @@ -64,6 +69,7 @@ + diff --git a/Objective-C/admob/BannerExample/BannerExample/ViewController.m b/Objective-C/admob/BannerExample/BannerExample/ViewController.m index 00fcad65..72a6d2d9 100644 --- a/Objective-C/admob/BannerExample/BannerExample/ViewController.m +++ b/Objective-C/admob/BannerExample/BannerExample/ViewController.m @@ -24,6 +24,7 @@ @interface ViewController () @property(nonatomic, weak) IBOutlet GADBannerView *bannerView; @property(weak, nonatomic) IBOutlet UIBarButtonItem *privacySettingsButton; +@property(weak, nonatomic) IBOutlet UIBarButtonItem *adInspectorButton; @end @@ -52,6 +53,29 @@ - (IBAction)privacySettingsTapped:(UIBarButtonItem *)sender { }]; } +- (IBAction)adInspectorTapped:(UIBarButtonItem *)sender { + [GADMobileAds.sharedInstance + presentAdInspectorFromViewController:self + completionHandler:^(NSError *_Nullable error) { + if (error) { + UIAlertController *alertController = [UIAlertController + alertControllerWithTitle:error.localizedDescription + message:@"Please try again later." + preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *defaultAction = + [UIAlertAction actionWithTitle:@"OK" + style:UIAlertActionStyleCancel + handler:^(UIAlertAction *action){ + }]; + + [alertController addAction:defaultAction]; + [self presentViewController:alertController + animated:YES + completion:nil]; + } + }]; +} + - (void)viewDidLoad { [super viewDidLoad]; diff --git a/Objective-C/admob/FullScreenNativeExample/FullScreenNativeExample/Base.lproj/Main.storyboard b/Objective-C/admob/FullScreenNativeExample/FullScreenNativeExample/Base.lproj/Main.storyboard index 4b02f2a6..581652c4 100644 --- a/Objective-C/admob/FullScreenNativeExample/FullScreenNativeExample/Base.lproj/Main.storyboard +++ b/Objective-C/admob/FullScreenNativeExample/FullScreenNativeExample/Base.lproj/Main.storyboard @@ -3,7 +3,7 @@ - + @@ -50,6 +50,11 @@ + + + + + @@ -57,6 +62,7 @@ + diff --git a/Objective-C/admob/FullScreenNativeExample/FullScreenNativeExample/MainViewController.m b/Objective-C/admob/FullScreenNativeExample/FullScreenNativeExample/MainViewController.m index 8c0d8c27..ee2527c4 100644 --- a/Objective-C/admob/FullScreenNativeExample/FullScreenNativeExample/MainViewController.m +++ b/Objective-C/admob/FullScreenNativeExample/FullScreenNativeExample/MainViewController.m @@ -25,6 +25,7 @@ @interface MainViewController () @property(strong, nonatomic) GADAdLoader *adLoader; @property(weak, nonatomic) IBOutlet UIBarButtonItem *privacySettingsButton; +@property(weak, nonatomic) IBOutlet UIBarButtonItem *adInspectorButton; @property(weak, nonatomic) IBOutlet UIButton *loadAdButton; @property(weak, nonatomic) IBOutlet UIButton *showAdButton; @@ -119,6 +120,29 @@ - (IBAction)privacySettingsButtonPressed:(UIBarButtonItem *)sender { }]; } +- (IBAction)adInspectorTapped:(UIBarButtonItem *)sender { + [GADMobileAds.sharedInstance + presentAdInspectorFromViewController:self + completionHandler:^(NSError *_Nullable error) { + if (error) { + UIAlertController *alertController = [UIAlertController + alertControllerWithTitle:error.localizedDescription + message:@"Please try again later." + preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *defaultAction = + [UIAlertAction actionWithTitle:@"OK" + style:UIAlertActionStyleCancel + handler:^(UIAlertAction *action){ + }]; + + [alertController addAction:defaultAction]; + [self presentViewController:alertController + animated:YES + completion:nil]; + } + }]; +} + - (IBAction)loadAdButtonPressed:(UIButton *)sender { self.loadAdButton.enabled = NO; self.showAdButton.enabled = NO; diff --git a/Objective-C/admob/InterstitialExample/InterstitialExample/Base.lproj/Main.storyboard b/Objective-C/admob/InterstitialExample/InterstitialExample/Base.lproj/Main.storyboard index 7c0a5b35..aa8a419a 100644 --- a/Objective-C/admob/InterstitialExample/InterstitialExample/Base.lproj/Main.storyboard +++ b/Objective-C/admob/InterstitialExample/InterstitialExample/Base.lproj/Main.storyboard @@ -1,9 +1,9 @@ - + - + @@ -87,6 +87,11 @@ + + + + + @@ -94,6 +99,7 @@ + diff --git a/Objective-C/admob/InterstitialExample/InterstitialExample/ViewController.h b/Objective-C/admob/InterstitialExample/InterstitialExample/ViewController.h index c915b91b..de6b580b 100644 --- a/Objective-C/admob/InterstitialExample/InterstitialExample/ViewController.h +++ b/Objective-C/admob/InterstitialExample/InterstitialExample/ViewController.h @@ -27,6 +27,9 @@ /// The privacy settings button. @property(nonatomic, weak) IBOutlet UIBarButtonItem *privacySettingsButton; +/// The ad inspector button. +@property(weak, nonatomic) IBOutlet UIBarButtonItem *adInspectorButton; + /// The game text. @property(nonatomic, weak) IBOutlet UILabel *gameText; diff --git a/Objective-C/admob/InterstitialExample/InterstitialExample/ViewController.m b/Objective-C/admob/InterstitialExample/InterstitialExample/ViewController.m index e7a27981..e23f2278 100644 --- a/Objective-C/admob/InterstitialExample/InterstitialExample/ViewController.m +++ b/Objective-C/admob/InterstitialExample/InterstitialExample/ViewController.m @@ -257,6 +257,29 @@ - (IBAction)privacySettingsTapped:(UIBarButtonItem *)sender { }]; } +- (IBAction)adInspectorTapped:(UIBarButtonItem *)sender { + [GADMobileAds.sharedInstance + presentAdInspectorFromViewController:self + completionHandler:^(NSError *_Nullable error) { + if (error) { + UIAlertController *alertController = [UIAlertController + alertControllerWithTitle:error.localizedDescription + message:@"Please try again later." + preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *defaultAction = + [UIAlertAction actionWithTitle:@"OK" + style:UIAlertActionStyleCancel + handler:^(UIAlertAction *action){ + }]; + + [alertController addAction:defaultAction]; + [self presentViewController:alertController + animated:YES + completion:nil]; + } + }]; +} + - (IBAction)playAgain:(id)sender { [self startNewGame]; diff --git a/Objective-C/admob/NativeAdvancedExample/NativeAdvancedExample/Base.lproj/Main.storyboard b/Objective-C/admob/NativeAdvancedExample/NativeAdvancedExample/Base.lproj/Main.storyboard index 6e579bbe..7823dc00 100644 --- a/Objective-C/admob/NativeAdvancedExample/NativeAdvancedExample/Base.lproj/Main.storyboard +++ b/Objective-C/admob/NativeAdvancedExample/NativeAdvancedExample/Base.lproj/Main.storyboard @@ -1,9 +1,9 @@ - + - + @@ -154,6 +154,11 @@ + + + + + @@ -161,6 +166,7 @@ + diff --git a/Objective-C/admob/NativeAdvancedExample/NativeAdvancedExample/ViewController.h b/Objective-C/admob/NativeAdvancedExample/NativeAdvancedExample/ViewController.h index 422ce5a3..ef0544ad 100644 --- a/Objective-C/admob/NativeAdvancedExample/NativeAdvancedExample/ViewController.h +++ b/Objective-C/admob/NativeAdvancedExample/NativeAdvancedExample/ViewController.h @@ -19,6 +19,9 @@ /// The privacy settings button. @property(nonatomic, weak) IBOutlet UIBarButtonItem *privacySettingsButton; +/// The ad inspector button. +@property(weak, nonatomic) IBOutlet UIBarButtonItem *adInspectorButton; + /// Container that holds the native ad. @property(nonatomic, weak) IBOutlet UIView *nativeAdPlaceholder; diff --git a/Objective-C/admob/NativeAdvancedExample/NativeAdvancedExample/ViewController.m b/Objective-C/admob/NativeAdvancedExample/NativeAdvancedExample/ViewController.m index cd5060a9..da213871 100644 --- a/Objective-C/admob/NativeAdvancedExample/NativeAdvancedExample/ViewController.m +++ b/Objective-C/admob/NativeAdvancedExample/NativeAdvancedExample/ViewController.m @@ -112,6 +112,29 @@ - (IBAction)privacySettingsTapped:(UIBarButtonItem *)sender { }]; } +- (IBAction)adInspectorTapped:(UIBarButtonItem *)sender { + [GADMobileAds.sharedInstance + presentAdInspectorFromViewController:self + completionHandler:^(NSError *_Nullable error) { + if (error) { + UIAlertController *alertController = [UIAlertController + alertControllerWithTitle:error.localizedDescription + message:@"Please try again later." + preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *defaultAction = + [UIAlertAction actionWithTitle:@"OK" + style:UIAlertActionStyleCancel + handler:^(UIAlertAction *action){ + }]; + + [alertController addAction:defaultAction]; + [self presentViewController:alertController + animated:YES + completion:nil]; + } + }]; +} + - (IBAction)refreshAd:(id)sender { // Loads a native ad. self.refreshButton.enabled = NO; diff --git a/Objective-C/admob/RewardedInterstitialExample/RewardedInterstitialExample/Base.lproj/Main.storyboard b/Objective-C/admob/RewardedInterstitialExample/RewardedInterstitialExample/Base.lproj/Main.storyboard index 61bea6eb..4d0c61bf 100644 --- a/Objective-C/admob/RewardedInterstitialExample/RewardedInterstitialExample/Base.lproj/Main.storyboard +++ b/Objective-C/admob/RewardedInterstitialExample/RewardedInterstitialExample/Base.lproj/Main.storyboard @@ -1,9 +1,9 @@ - + - + @@ -76,6 +76,11 @@ + + + + + @@ -83,6 +88,7 @@ + diff --git a/Objective-C/admob/RewardedInterstitialExample/RewardedInterstitialExample/ViewController.m b/Objective-C/admob/RewardedInterstitialExample/RewardedInterstitialExample/ViewController.m index 89eaa385..5c6dec51 100644 --- a/Objective-C/admob/RewardedInterstitialExample/RewardedInterstitialExample/ViewController.m +++ b/Objective-C/admob/RewardedInterstitialExample/RewardedInterstitialExample/ViewController.m @@ -43,6 +43,9 @@ @interface ViewController () /// The privacy settings button. @property(weak, nonatomic) IBOutlet UIBarButtonItem *privacySettingsButton; +/// The ad inspector button. +@property(weak, nonatomic) IBOutlet UIBarButtonItem *adInspectorButton; + /// The game text. @property(nonatomic, weak) IBOutlet UILabel *gameText; @@ -318,6 +321,29 @@ - (IBAction)privacySettingsTapped:(UIBarButtonItem *)sender { }]; } +- (IBAction)adInspectorTapped:(UIBarButtonItem *)sender { + [GADMobileAds.sharedInstance + presentAdInspectorFromViewController:self + completionHandler:^(NSError *_Nullable error) { + if (error) { + UIAlertController *alertController = [UIAlertController + alertControllerWithTitle:error.localizedDescription + message:@"Please try again later." + preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *defaultAction = + [UIAlertAction actionWithTitle:@"OK" + style:UIAlertActionStyleCancel + handler:^(UIAlertAction *action){ + }]; + + [alertController addAction:defaultAction]; + [self presentViewController:alertController + animated:YES + completion:nil]; + } + }]; +} + - (IBAction)playAgain:(id)sender { [self startNewGame]; if (GoogleMobileAdsConsentManager.sharedInstance.canRequestAds) { diff --git a/Objective-C/admob/RewardedVideoExample/RewardedVideoExample/Base.lproj/Main.storyboard b/Objective-C/admob/RewardedVideoExample/RewardedVideoExample/Base.lproj/Main.storyboard index 9b2e311a..b6e64c44 100644 --- a/Objective-C/admob/RewardedVideoExample/RewardedVideoExample/Base.lproj/Main.storyboard +++ b/Objective-C/admob/RewardedVideoExample/RewardedVideoExample/Base.lproj/Main.storyboard @@ -1,9 +1,9 @@ - + - + @@ -87,6 +87,11 @@ + + + + + @@ -94,6 +99,7 @@ + diff --git a/Objective-C/admob/RewardedVideoExample/RewardedVideoExample/ViewController.m b/Objective-C/admob/RewardedVideoExample/RewardedVideoExample/ViewController.m index 01cd60bb..dce0e753 100644 --- a/Objective-C/admob/RewardedVideoExample/RewardedVideoExample/ViewController.m +++ b/Objective-C/admob/RewardedVideoExample/RewardedVideoExample/ViewController.m @@ -38,6 +38,9 @@ @interface ViewController () /// The privacy settings button. @property(weak, nonatomic) IBOutlet UIBarButtonItem *privacySettingsButton; +/// The ad inspector button. +@property(weak, nonatomic) IBOutlet UIBarButtonItem *adInspectorButton; + /// The game text. @property(weak, nonatomic) IBOutlet UILabel *gameLabel; @@ -259,6 +262,29 @@ - (IBAction)privacySettingsTapped:(UIBarButtonItem *)sender { }]; } +- (IBAction)adInspectorTapped:(UIBarButtonItem *)sender { + [GADMobileAds.sharedInstance + presentAdInspectorFromViewController:self + completionHandler:^(NSError *_Nullable error) { + if (error) { + UIAlertController *alertController = [UIAlertController + alertControllerWithTitle:error.localizedDescription + message:@"Please try again later." + preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *defaultAction = + [UIAlertAction actionWithTitle:@"OK" + style:UIAlertActionStyleCancel + handler:^(UIAlertAction *action){ + }]; + + [alertController addAction:defaultAction]; + [self presentViewController:alertController + animated:YES + completion:nil]; + } + }]; +} + - (IBAction)playAgain:(id)sender { [self startNewGame]; if (GoogleMobileAdsConsentManager.sharedInstance.canRequestAds) {