[ios][admob] Ensure previous banner is removed from view when re-rendering
This commit is contained in:
parent
0525672860
commit
6af227b648
|
@ -7,7 +7,8 @@
|
||||||
|
|
||||||
@interface BannerComponent : UIView <GADBannerViewDelegate>
|
@interface BannerComponent : UIView <GADBannerViewDelegate>
|
||||||
|
|
||||||
@property GADBannerView *banner;
|
@property GADBannerView *banner;
|
||||||
|
@property (nonatomic, assign) BOOL requested;
|
||||||
|
|
||||||
@property (nonatomic, copy) NSString *size;
|
@property (nonatomic, copy) NSString *size;
|
||||||
@property (nonatomic, copy) NSString *unitId;
|
@property (nonatomic, copy) NSString *unitId;
|
||||||
|
|
|
@ -5,6 +5,9 @@
|
||||||
@implementation BannerComponent
|
@implementation BannerComponent
|
||||||
|
|
||||||
- (void)initBanner:(GADAdSize)adSize {
|
- (void)initBanner:(GADAdSize)adSize {
|
||||||
|
if (_requested) {
|
||||||
|
[_banner removeFromSuperview];
|
||||||
|
}
|
||||||
_banner = [[GADBannerView alloc] initWithAdSize:adSize];
|
_banner = [[GADBannerView alloc] initWithAdSize:adSize];
|
||||||
_banner.rootViewController = [UIApplication sharedApplication].delegate.window.rootViewController;
|
_banner.rootViewController = [UIApplication sharedApplication].delegate.window.rootViewController;
|
||||||
_banner.delegate = self;
|
_banner.delegate = self;
|
||||||
|
@ -27,6 +30,7 @@
|
||||||
|
|
||||||
- (void)requestAd {
|
- (void)requestAd {
|
||||||
if (_unitId == nil || _size == nil || _request == nil) {
|
if (_unitId == nil || _size == nil || _request == nil) {
|
||||||
|
[self setRequested:NO];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,6 +43,7 @@
|
||||||
}];
|
}];
|
||||||
|
|
||||||
_banner.adUnitID = _unitId;
|
_banner.adUnitID = _unitId;
|
||||||
|
[self setRequested:YES];
|
||||||
[_banner loadRequest:[RNFirebaseAdMob buildRequest:_request]];
|
[_banner loadRequest:[RNFirebaseAdMob buildRequest:_request]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue