Skip to content

Commit

Permalink
fix(ios): banners not properly destroyed
Browse files Browse the repository at this point in the history
  • Loading branch information
dylancom committed Dec 27, 2023
1 parent bfec491 commit cef8f9e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ios/RNGoogleMobileAds/RNGoogleMobileAdsBannerComponent.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@

@implementation RNGoogleMobileAdsBannerComponent

- (void)removeFromSuperview {
if (_banner) {
[_banner removeFromSuperview];
_banner = nil;
}

[super removeFromSuperview];
}

- (void)didSetProps:(NSArray<NSString *> *)changedProps {
if (_propsChanged) {
[self requestAd];
Expand Down
7 changes: 7 additions & 0 deletions ios/RNGoogleMobileAds/RNGoogleMobileAdsBannerView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &
[super updateProps:props oldProps:oldProps];
}

- (void)dealloc {
if (_banner) {
[_banner removeFromSuperview];
_banner = nil;
}
}

#pragma mark - Methods

- (void)initBanner:(GADAdSize)adSize {
Expand Down

0 comments on commit cef8f9e

Please sign in to comment.