Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ios): register asset view properly in old arch #696

Merged
merged 2 commits into from
Jan 23, 2025
Merged
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
13 changes: 9 additions & 4 deletions ios/RNGoogleMobileAds/RNGoogleMobileAdsNativeView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ - (void)setResponseId:(NSString *)responseId {
- (void)registerAsset:(NSString *)assetType reactTag:(NSInteger)reactTag {
RCTExecuteOnMainQueue(^{
UIView *view = [_bridge.uiManager viewForReactTag:@(reactTag)];
if (!view) {
RCTLogError(@"Cannot find NativeAssetView with tag #%zd while registering asset type %@",
reactTag, assetType);
return;
}

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

RCT_EXPORT_METHOD(registerAsset
: (nonnull NSNumber *)reactTag commandID
: (NSInteger)commandID commandArgs
: (NSArray<id> *)commandArgs) {
: (nonnull NSNumber *)reactTag assetType
: (nonnull NSString *)assetType assetReactTag
: (nonnull NSNumber *)assetReactTag) {
[self.bridge.uiManager
addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
RNGoogleMobileAdsNativeView *view = viewRegistry[reactTag];
if (!view || ![view isKindOfClass:[RNGoogleMobileAdsNativeView class]]) {
RCTLogError(@"Cannot find NativeView with tag #%@", reactTag);
return;
}
[view registerAsset:commandArgs[0] reactTag:((NSNumber *)commandArgs[1]).intValue];
[view registerAsset:assetType reactTag:assetReactTag.intValue];
}];
}
#endif
Expand Down
Loading