Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Ad Inspector support. #461

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="21507" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="yNo-FF-Eut">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="yNo-FF-Eut">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21505"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22684"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand Down Expand Up @@ -104,13 +104,19 @@
</constraints>
</view>
<navigationItem key="navigationItem" id="0rM-wW-YPw">
<barButtonItem key="leftBarButtonItem" title="Ad Inspector" id="dwx-Ie-hfA">
<connections>
<action selector="adInspectorTapped:" destination="BYZ-38-t0r" id="S2D-aM-G2H"/>
</connections>
</barButtonItem>
<barButtonItem key="rightBarButtonItem" enabled="NO" title="Privacy Settings" id="jOf-sG-VlR">
<connections>
<action selector="privacySettingsTapped:" destination="BYZ-38-t0r" id="cfa-M0-nYH"/>
</connections>
</barButtonItem>
</navigationItem>
<connections>
<outlet property="adInspectorButton" destination="dwx-Ie-hfA" id="9ZX-am-RLh"/>
<outlet property="privacySettingsButton" destination="jOf-sG-VlR" id="sYJ-FJ-Dq1"/>
</connections>
</viewController>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@

@property(weak, nonatomic) IBOutlet UIBarButtonItem *privacySettingsButton;

@property(weak, nonatomic) IBOutlet UIBarButtonItem *adInspectorButton;

@end
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
//

#import "MainViewController.h"

#import <GoogleMobileAds/GoogleMobileAds.h>
#import "GoogleMobileAdsConsentManager.h"

@interface MainViewController ()
Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="22154" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES" initialViewController="hrC-kg-0cx">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES" initialViewController="hrC-kg-0cx">
<device id="retina5_9" orientation="portrait" appearance="light"/>
<dependencies>
<deployment version="2304" identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22130"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22684"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
Expand Down Expand Up @@ -56,6 +56,11 @@
</view>
<toolbarItems/>
<navigationItem key="navigationItem" id="OeE-zL-ruC">
<barButtonItem key="leftBarButtonItem" title="Ad Inspector" id="avb-Xc-8GG">
<connections>
<action selector="adInspectorTapped:" destination="BYZ-38-t0r" id="PVy-Qm-HG0"/>
</connections>
</barButtonItem>
<barButtonItem key="rightBarButtonItem" enabled="NO" title="Privacy Settings" id="D2V-uK-vBr">
<connections>
<action selector="privacySettingsTapped:" destination="BYZ-38-t0r" id="35e-S9-mPt"/>
Expand All @@ -64,6 +69,7 @@
</navigationItem>
<nil key="simulatedBottomBarMetrics"/>
<connections>
<outlet property="adInspectorButton" destination="avb-Xc-8GG" id="QEQ-xq-DYy"/>
<outlet property="bannerView" destination="b5b-Tm-bLe" id="cWf-NW-i8E"/>
<outlet property="privacySettingsButton" destination="D2V-uK-vBr" id="eKt-Ys-Cxs"/>
</connections>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ @interface ViewController () <GADBannerViewDelegate>

@property(nonatomic, weak) IBOutlet GAMBannerView *bannerView;
@property(weak, nonatomic) IBOutlet UIBarButtonItem *privacySettingsButton;
@property(weak, nonatomic) IBOutlet UIBarButtonItem *adInspectorButton;

@end

Expand Down Expand Up @@ -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];

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="22113.1" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES" initialViewController="bCS-So-gjg">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES" initialViewController="bCS-So-gjg">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22089"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22684"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
Expand Down Expand Up @@ -174,13 +174,19 @@
</constraints>
</view>
<navigationItem key="navigationItem" id="EiA-U5-8is">
<barButtonItem key="leftBarButtonItem" title="Ad Inspector" id="6cK-Lg-xlj">
<connections>
<action selector="adInspectorTapped:" destination="m1l-bW-rbg" id="LAB-Ga-XO0"/>
</connections>
</barButtonItem>
<barButtonItem key="rightBarButtonItem" enabled="NO" title="Privacy Settings" id="rxR-FT-kD4">
<connections>
<action selector="privacySettingsTapped:" destination="m1l-bW-rbg" id="qDd-eV-g90"/>
</connections>
</barButtonItem>
</navigationItem>
<connections>
<outlet property="adInspectorButton" destination="6cK-Lg-xlj" id="vX1-4N-rMb"/>
<outlet property="customNativeAdSwitch" destination="Ea3-6P-gPY" id="4S5-1J-PZo"/>
<outlet property="nativeAdPlaceholder" destination="1Sh-Io-8vE" id="0PL-aB-bPq"/>
<outlet property="nativeAdSwitch" destination="Ng2-tC-5a0" id="lrD-91-Cef"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="22113.1" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES" initialViewController="QKh-B8-b5v">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES" initialViewController="QKh-B8-b5v">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22089"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22684"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand Down Expand Up @@ -86,13 +86,19 @@
</constraints>
</view>
<navigationItem key="navigationItem" id="Q4f-q9-ymA">
<barButtonItem key="leftBarButtonItem" title="Ad Inspector" id="e9d-Qw-c2X">
<connections>
<action selector="adInspectorTapped:" destination="BYZ-38-t0r" id="yfQ-Qg-e9q"/>
</connections>
</barButtonItem>
<barButtonItem key="rightBarButtonItem" enabled="NO" title="Privacy Settings" id="qoL-oN-ZSm">
<connections>
<action selector="privacySettingsTapped:" destination="BYZ-38-t0r" id="bxY-OT-3fI"/>
</connections>
</barButtonItem>
</navigationItem>
<connections>
<outlet property="adInspectorButton" destination="e9d-Qw-c2X" id="4lF-QF-eRc"/>
<outlet property="gameText" destination="Axu-KP-hMF" id="gzf-u2-Ph4"/>
<outlet property="gameView" destination="WRu-cy-KFK" id="pDT-t5-yj2"/>
<outlet property="loadingSpinner" destination="Hro-fg-3MF" id="tO3-aG-IXf"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="22113.1" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES" initialViewController="VCq-9h-Ghp">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES" initialViewController="VCq-9h-Ghp">
<device id="retina5_9" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22089"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22684"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
Expand Down Expand Up @@ -76,13 +76,19 @@
</constraints>
</view>
<navigationItem key="navigationItem" id="Itz-Jw-Nh2">
<barButtonItem key="leftBarButtonItem" title="Ad Inspector" id="sxO-0o-1sa">
<connections>
<action selector="adInspectorTapped:" destination="BYZ-38-t0r" id="EJt-sq-v2j"/>
</connections>
</barButtonItem>
<barButtonItem key="rightBarButtonItem" enabled="NO" title="Privacy Settings" id="04C-Fc-x4d">
<connections>
<action selector="privacySettingsTapped:" destination="BYZ-38-t0r" id="o0a-Ga-IOJ"/>
</connections>
</barButtonItem>
</navigationItem>
<connections>
<outlet property="adInspectorButton" destination="sxO-0o-1sa" id="aNy-TW-ULE"/>
<outlet property="coinCountLabel" destination="K63-xT-qpW" id="cAl-QK-AAy"/>
<outlet property="gameText" destination="hNG-Yh-paY" id="EaJ-Mh-Htn"/>
<outlet property="playAgainButton" destination="YbK-8l-i8l" id="SKB-fc-Knv"/>
Expand Down
Loading
Loading