Skip to content

Commit b1ea6c1

Browse files
authored
fix(ios): register asset view properly in old arch
1 parent f44c27e commit b1ea6c1

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

ios/RNGoogleMobileAds/RNGoogleMobileAdsNativeView.mm

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ - (void)setResponseId:(NSString *)responseId {
127127
- (void)registerAsset:(NSString *)assetType reactTag:(NSInteger)reactTag {
128128
RCTExecuteOnMainQueue(^{
129129
UIView *view = [_bridge.uiManager viewForReactTag:@(reactTag)];
130+
if (!view) {
131+
RCTLogError(@"Cannot find NativeAssetView with tag #%zd while registering asset type %@",
132+
reactTag, assetType);
133+
return;
134+
}
130135

131136
if ([assetType isEqual:@"media"] && [view isKindOfClass:RNGoogleMobileAdsMediaView.class]) {
132137
#ifdef RCT_NEW_ARCH_ENABLED
@@ -194,17 +199,17 @@ - (UIView *)view {
194199
}
195200

196201
RCT_EXPORT_METHOD(registerAsset
197-
: (nonnull NSNumber *)reactTag commandID
198-
: (NSInteger)commandID commandArgs
199-
: (NSArray<id> *)commandArgs) {
202+
: (nonnull NSNumber *)reactTag assetType
203+
: (nonnull NSString *)assetType assetReactTag
204+
: (nonnull NSNumber *)assetReactTag) {
200205
[self.bridge.uiManager
201206
addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
202207
RNGoogleMobileAdsNativeView *view = viewRegistry[reactTag];
203208
if (!view || ![view isKindOfClass:[RNGoogleMobileAdsNativeView class]]) {
204209
RCTLogError(@"Cannot find NativeView with tag #%@", reactTag);
205210
return;
206211
}
207-
[view registerAsset:commandArgs[0] reactTag:((NSNumber *)commandArgs[1]).intValue];
212+
[view registerAsset:assetType reactTag:assetReactTag.intValue];
208213
}];
209214
}
210215
#endif

0 commit comments

Comments
 (0)