@@ -54,13 +54,13 @@ - (GADAdSize)getAdSizeFromString:(NSString *)bannerSize
54
54
return kGADAdSizeSmartBannerPortrait ;
55
55
} else if ([bannerSize isEqualToString: @" smartBannerLandscape" ]) {
56
56
return kGADAdSizeSmartBannerLandscape ;
57
- }
58
- else {
57
+ } else {
59
58
return kGADAdSizeBanner ;
60
59
}
61
60
}
62
61
63
- -(void )loadBanner {
62
+ -(void )loadBanner
63
+ {
64
64
if (_adUnitID && _bannerSize) {
65
65
GADAdSize size = [self getAdSizeFromString: _bannerSize];
66
66
_bannerView = [[GADBannerView alloc ] initWithAdSize: size];
@@ -84,7 +84,6 @@ -(void)loadBanner {
84
84
request.testDevices = @[_testDeviceID];
85
85
}
86
86
}
87
-
88
87
[_bannerView loadRequest: request];
89
88
}
90
89
}
@@ -100,36 +99,32 @@ - (void)setBannerSize:(NSString *)bannerSize
100
99
}
101
100
}
102
101
103
-
104
-
105
102
- (void )setAdUnitID : (NSString *)adUnitID
106
103
{
107
104
if (![adUnitID isEqual: _adUnitID]) {
108
105
_adUnitID = adUnitID;
109
106
if (_bannerView) {
110
107
[_bannerView removeFromSuperview ];
111
108
}
112
-
113
109
[self loadBanner ];
114
110
}
115
111
}
112
+
116
113
- (void )setTestDeviceID : (NSString *)testDeviceID
117
114
{
118
115
if (![testDeviceID isEqual: _testDeviceID]) {
119
116
_testDeviceID = testDeviceID;
120
117
if (_bannerView) {
121
118
[_bannerView removeFromSuperview ];
122
119
}
123
-
124
120
[self loadBanner ];
125
121
}
126
122
}
127
123
128
124
-(void )layoutSubviews
129
125
{
130
- [super layoutSubviews ];
131
-
132
- _bannerView.frame = CGRectMake (
126
+ [super layoutSubviews ];
127
+ self.frame = CGRectMake (
133
128
self.bounds .origin .x ,
134
129
self.bounds .origin .x ,
135
130
_bannerView.frame .size .width ,
@@ -144,35 +139,41 @@ - (void)removeFromSuperview
144
139
}
145
140
146
141
// / Tells the delegate an ad request loaded an ad.
147
- - (void )adViewDidReceiveAd : (GADBannerView *)adView {
142
+ - (void )adViewDidReceiveAd : (GADBannerView *)adView
143
+ {
148
144
[_eventDispatcher sendInputEventWithName: @" onAdViewDidReceiveAd" body: @{ @" target" : self.reactTag }];
149
145
}
150
146
151
147
// / Tells the delegate an ad request failed.
152
148
- (void )adView : (GADBannerView *)adView
153
- didFailToReceiveAdWithError : (GADRequestError *)error {
149
+ didFailToReceiveAdWithError : (GADRequestError *)error
150
+ {
154
151
[_eventDispatcher sendInputEventWithName: @" onDidFailToReceiveAdWithError" body: @{ @" target" : self.reactTag , @" error" : [error localizedDescription ] }];
155
152
}
156
153
157
154
// / Tells the delegate that a full screen view will be presented in response
158
155
// / to the user clicking on an ad.
159
- - (void )adViewWillPresentScreen : (GADBannerView *)adView {
156
+ - (void )adViewWillPresentScreen : (GADBannerView *)adView
157
+ {
160
158
[_eventDispatcher sendInputEventWithName: @" onAdViewWillPresentScreen" body: @{ @" target" : self.reactTag }];
161
159
}
162
160
163
161
// / Tells the delegate that the full screen view will be dismissed.
164
- - (void )adViewWillDismissScreen : (GADBannerView *)adView {
162
+ - (void )adViewWillDismissScreen : (GADBannerView *)adView
163
+ {
165
164
[_eventDispatcher sendInputEventWithName: @" onAdViewWillDismissScreen" body: @{ @" target" : self.reactTag }];
166
165
}
167
166
168
167
// / Tells the delegate that the full screen view has been dismissed.
169
- - (void )adViewDidDismissScreen : (GADBannerView *)adView {
168
+ - (void )adViewDidDismissScreen : (GADBannerView *)adView
169
+ {
170
170
[_eventDispatcher sendInputEventWithName: @" onAdViewDidDismissScreen" body: @{ @" target" : self.reactTag }];
171
171
}
172
172
173
173
// / Tells the delegate that a user click will open another app (such as
174
174
// / the App Store), backgrounding the current app.
175
- - (void )adViewWillLeaveApplication : (GADBannerView *)adView {
175
+ - (void )adViewWillLeaveApplication : (GADBannerView *)adView
176
+ {
176
177
[_eventDispatcher sendInputEventWithName: @" onAdViewWillLeaveApplication" body: @{ @" target" : self.reactTag }];
177
178
}
178
179
0 commit comments