From d5749e093e5309162d64aa814d4aa94e0df242a2 Mon Sep 17 00:00:00 2001 From: WOO HYUK KO Date: Sun, 12 May 2024 07:41:26 +0900 Subject: [PATCH] fix(iOS): Replace unsupported nullish coalescing operator for older iOS versions (#3388) --- apple/RNCWebViewImpl.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apple/RNCWebViewImpl.m b/apple/RNCWebViewImpl.m index bf166709f..3203f8012 100644 --- a/apple/RNCWebViewImpl.m +++ b/apple/RNCWebViewImpl.m @@ -1683,10 +1683,10 @@ - (void)setInjectedJavaScriptObject:(NSString *)source initWithSource: [ NSString stringWithFormat: - @"window.%@ ??= {};" + @"window.%@ = window.%@ || {};" "window.%@.injectedObjectJson = function () {" " return `%@`;" - "};", MessageHandlerName, MessageHandlerName, source + "};", MessageHandlerName, MessageHandlerName, MessageHandlerName, source ] injectionTime:WKUserScriptInjectionTimeAtDocumentStart /* TODO: For a separate (minor) PR: use logic like this (as react-native-wkwebview does) so that messaging can be used in all frames if desired. @@ -1734,10 +1734,10 @@ - (void)setMessagingEnabled:(BOOL)messagingEnabled { initWithSource: [ NSString stringWithFormat: - @"window.%@ ??= {};" + @"window.%@ = window.%@ || {};" "window.%@.postMessage = function (data) {" " window.webkit.messageHandlers.%@.postMessage(String(data));" - "};", MessageHandlerName, MessageHandlerName, MessageHandlerName + "};", MessageHandlerName, MessageHandlerName, MessageHandlerName, MessageHandlerName ] injectionTime:WKUserScriptInjectionTimeAtDocumentStart /* TODO: For a separate (minor) PR: use logic like this (as react-native-wkwebview does) so that messaging can be used in all frames if desired.