Skip to content
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
Expand Up @@ -35,7 +35,6 @@
A8C2004A2EBD077D004E4D77 /* MediationSnippets.m in Sources */ = {isa = PBXBuildFile; fileRef = A8C200492EBD0778004E4D77 /* MediationSnippets.m */; };
A8C4F2A12EDF582B00A8615A /* ImpressionLevelAdRevenueSnippets.m in Sources */ = {isa = PBXBuildFile; fileRef = A8C4F2A02EDF582500A8615A /* ImpressionLevelAdRevenueSnippets.m */; };
A8C4F2A32EDF92C600A8615A /* BannerSnippets.m in Sources */ = {isa = PBXBuildFile; fileRef = EF25D0212E4B916800688F43 /* BannerSnippets.m */; };
A8C4F2A52EDF9C4900A8615A /* BuildFile in Sources */ = {isa = PBXBuildFile; };
A8C4F2A92EE1DE8B00A8615A /* AdManagerBannerSnippets.m in Sources */ = {isa = PBXBuildFile; fileRef = A8C4F2A82EE1DE8B00A8615A /* AdManagerBannerSnippets.m */; };
AEC9AC0D2140985100E1DC91 /* AdMobNativeCustomMuteThisAdViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = AEC9AC0C2140985000E1DC91 /* AdMobNativeCustomMuteThisAdViewController.m */; };
AED1110E20320ABC00EA4BEE /* SimpleNativeAdView.xib in Resources */ = {isa = PBXBuildFile; fileRef = AED1110C20320ABB00EA4BEE /* SimpleNativeAdView.xib */; };
Expand Down Expand Up @@ -311,7 +310,6 @@
4A96E7531B8578D600031470 /* AdMobBannerSizesViewController.m in Sources */,
AEC9AC0D2140985100E1DC91 /* AdMobNativeCustomMuteThisAdViewController.m in Sources */,
5038FC6D2511428A00750F9C /* MainViewController.m in Sources */,
A8C4F2A52EDF9C4900A8615A /* BuildFile in Sources */,
A846F1C32E2584AD00F96E49 /* RewardedAdSnippets.m in Sources */,
50DC0CF9212F1C4000424CC7 /* GAMCategoryExclusionsViewController.m in Sources */,
A8C4F2A12EDF582B00A8615A /* ImpressionLevelAdRevenueSnippets.m in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#import <GoogleMobileAds/GoogleMobileAds.h>
#import <UIKit/UIKit.h>

@interface AdManagerBannerSnippets : UIViewController
@interface AdManagerBannerSnippets : UIViewController <GADAppEventDelegate>

@property(nonatomic, strong) GAMBannerView *bannerView;

Expand Down Expand Up @@ -90,4 +90,42 @@ - (void)loadInlineAdaptiveBanner {
[bannerView loadRequest:[GAMRequest request]];
}

- (void)enableManualImpressionCountingForBannerView {
// [START enable_manual_impression_counting]
self.bannerView.enableManualImpressions = YES;
// [END enable_manual_impression_counting]
}

- (void)recordManualImpression {
// [START record_manual_impression]
[self.bannerView recordImpression];
// [END record_manual_impression]
}

- (void)setAppEventListener {
// [START set_app_event_listener]
// Set this property before making the request for an ad.
self.bannerView.appEventDelegate = self;
// [END set_app_event_listener]
}

// [START app_events]
- (void)bannerView:(GAMBannerView *)banner
didReceiveAppEvent:(NSString *)name
withInfo:(NSString *)info {
if ([name isEqual:@"color"]) {
if ([info isEqual:@"green"]) {
// Set background color to green.
self.view.backgroundColor = [UIColor greenColor];
} else if ([info isEqual:@"blue"]) {
// Set background color to blue.
self.view.backgroundColor = [UIColor blueColor];
} else {
// Set background color to black.
self.view.backgroundColor = [UIColor blackColor];
}
}
}
// [END app_events]

@end
7 changes: 4 additions & 3 deletions Swift/advanced/APIDemo/APIDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
507818F9219A418100E5A44A /* AdManagerAppEventsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 507818F2219A418000E5A44A /* AdManagerAppEventsViewController.swift */; };
507818FA219A418100E5A44A /* AdManagerFluidAdSizeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 507818F3219A418100E5A44A /* AdManagerFluidAdSizeViewController.swift */; };
A80EED082EDE280A005DFC04 /* MobileAdsSnippets.swift in Sources */ = {isa = PBXBuildFile; fileRef = A80EED072EDE2807005DFC04 /* MobileAdsSnippets.swift */; };
A816AF1C2EE1E6190074BDF2 /* AdManagerBannerSnippets.swift in Sources */ = {isa = PBXBuildFile; fileRef = A816AF1B2EE1E6190074BDF2 /* AdManagerBannerSnippets.swift */; };
A8265F6F2E4F883500A9C150 /* ResponseInfoSnippets.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8265F6E2E4F883500A9C150 /* ResponseInfoSnippets.swift */; };
A8265F712E4F884500A9C150 /* NativeAdOptionsSnippets.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8265F702E4F884100A9C150 /* NativeAdOptionsSnippets.swift */; };
A846F1C12E2583D200F96E49 /* RewardedAdSnippets.swift in Sources */ = {isa = PBXBuildFile; fileRef = A846F1C02E2583CF00F96E49 /* RewardedAdSnippets.swift */; };
Expand All @@ -35,7 +36,6 @@
A8C200482EBD03D5004E4D77 /* MediationSnippets.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8C200472EBD03D1004E4D77 /* MediationSnippets.swift */; };
A8C4F29F2EDF549D00A8615A /* ImpressionLevelAdRevenueSnippets.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8C4F29E2EDF549800A8615A /* ImpressionLevelAdRevenueSnippets.swift */; };
A8C4F2A22EDF8E2300A8615A /* BannerSnippets.swift in Sources */ = {isa = PBXBuildFile; fileRef = EF25D0272E4B97F000688F43 /* BannerSnippets.swift */; };
A8C4F2A72EDF9DD500A8615A /* AdManagerBannerSnippets.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8C4F2A62EDF9DD100A8615A /* AdManagerBannerSnippets.swift */; };
AE3068CA21221F7E006D7843 /* AdMobNativeCustomMuteThisAdViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE3068C921221F7E006D7843 /* AdMobNativeCustomMuteThisAdViewController.swift */; };
AED1111F203213FC00EA4BEE /* SimpleNativeAdView.xib in Resources */ = {isa = PBXBuildFile; fileRef = AED11117203213F300EA4BEE /* SimpleNativeAdView.xib */; };
AED11120203213FC00EA4BEE /* UnifiedNativeAdView.xib in Resources */ = {isa = PBXBuildFile; fileRef = AED11118203213F500EA4BEE /* UnifiedNativeAdView.xib */; };
Expand Down Expand Up @@ -69,6 +69,7 @@
507818F2219A418000E5A44A /* AdManagerAppEventsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AdManagerAppEventsViewController.swift; sourceTree = "<group>"; };
507818F3219A418100E5A44A /* AdManagerFluidAdSizeViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AdManagerFluidAdSizeViewController.swift; sourceTree = "<group>"; };
A80EED072EDE2807005DFC04 /* MobileAdsSnippets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MobileAdsSnippets.swift; sourceTree = "<group>"; };
A816AF1B2EE1E6190074BDF2 /* AdManagerBannerSnippets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdManagerBannerSnippets.swift; sourceTree = "<group>"; };
A8265F6E2E4F883500A9C150 /* ResponseInfoSnippets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResponseInfoSnippets.swift; sourceTree = "<group>"; };
A8265F702E4F884100A9C150 /* NativeAdOptionsSnippets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NativeAdOptionsSnippets.swift; sourceTree = "<group>"; };
A846F1C02E2583CF00F96E49 /* RewardedAdSnippets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RewardedAdSnippets.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -153,7 +154,7 @@
A8B650372DD63E0F00AE1D3F /* Snippets */ = {
isa = PBXGroup;
children = (
A8C4F2A62EDF9DD100A8615A /* AdManagerBannerSnippets.swift */,
A816AF1B2EE1E6190074BDF2 /* AdManagerBannerSnippets.swift */,
1C1F6FC52E70E87700B6D6F5 /* AdManagerSCARSnippets.swift */,
1C1F6FC62E70E87700B6D6F5 /* AdMobSCARSnippets.swift */,
A86568AA2E254CD100D360C3 /* ATTSnippets.swift */,
Expand Down Expand Up @@ -283,6 +284,7 @@
507818F8219A418100E5A44A /* AdManagerCustomVideoControlsController.swift in Sources */,
507818FA219A418100E5A44A /* AdManagerFluidAdSizeViewController.swift in Sources */,
A86568AB2E254CD500D360C3 /* ATTSnippets.swift in Sources */,
A816AF1C2EE1E6190074BDF2 /* AdManagerBannerSnippets.swift in Sources */,
4A7A6CD71C76237500FB1A32 /* Constants.swift in Sources */,
A8C200482EBD03D5004E4D77 /* MediationSnippets.swift in Sources */,
507818F6219A418100E5A44A /* AdManagerPPIDViewController.swift in Sources */,
Expand All @@ -293,7 +295,6 @@
A8B650362DD63E0300AE1D3F /* RequestConfigurationSnippets.swift in Sources */,
EF25D02C2E4B980C00688F43 /* RewardedInterstitialAdSnippets.swift in Sources */,
4AA7D6AE1C626F2D00DFD2EB /* AdMobBannerSizesViewController.swift in Sources */,
A8C4F2A72EDF9DD500A8615A /* AdManagerBannerSnippets.swift in Sources */,
AE3068CA21221F7E006D7843 /* AdMobNativeCustomMuteThisAdViewController.swift in Sources */,
507818F4219A418100E5A44A /* AdManagerMultipleAdSizesViewController.swift in Sources */,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import GoogleMobileAds

private class BannerSnippets: UIViewController {
private class AdManagerBannerSnippets: UIViewController, AppEventDelegate {

var bannerView: AdManagerBannerView!

Expand Down Expand Up @@ -75,4 +75,42 @@ private class BannerSnippets: UIViewController {
bannerView.adUnitID = "/21775744923/example/adaptive-banner"
bannerView.load(AdManagerRequest())
}

private func enableManualImpressionCountingForBannerView() {
// [START enable_manual_impression_counting]
bannerView.enableManualImpressions = true
// [END enable_manual_impression_counting]
}

private func recordManualImpression() {
// [START record_manual_impression]
bannerView.recordImpression()
// [END record_manual_impression]
}

private func setAppEventListener() {
// [START set_app_event_listener]
// Set this property before making the request for an ad.
bannerView.appEventDelegate = self
// [END set_app_event_listener]
}

// [START app_events]
func bannerView(
_ banner: AdManagerBannerView, didReceiveAppEvent name: String, withInfo info: String?
) {
if name == "color" {
if info == "green" {
// Set background color to green.
view.backgroundColor = UIColor.green
} else if info == "blue" {
// Set background color to blue.
view.backgroundColor = UIColor.blue
} else {
// Set background color to black.
view.backgroundColor = UIColor.black
}
}
}
// [END app_events]
}
Loading