Created
October 23, 2023 17:59
-
-
Save SudoPlz/003d1f70a68034d5a9639d2d0dfca413 to your computer and use it in GitHub Desktop.
Revisions
-
SudoPlz created this gist
Oct 23, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ diff --git a/node_modules/react-native/Libraries/LinkingIOS/RCTLinkingManager.mm b/node_modules/react-native/Libraries/LinkingIOS/RCTLinkingManager.mm index cfa9078..6a3daf5 100644 --- a/node_modules/react-native/Libraries/LinkingIOS/RCTLinkingManager.mm +++ b/node_modules/react-native/Libraries/LinkingIOS/RCTLinkingManager.mm @@ -18,15 +18,19 @@ static void postNotificationWithURL(NSURL *URL, id sender) { + NSDictionary<NSString *, id> *payload = @{@"url" : URL.absoluteString}; [[NSNotificationCenter defaultCenter] postNotificationName:kOpenURLNotification object:sender userInfo:payload]; } @interface RCTLinkingManager () <NativeLinkingManagerSpec> + @property (nonatomic, strong) NSURL * lastDispatchedLink; @end @implementation RCTLinkingManager +static NSURL *lastDispatchedLink; + RCT_EXPORT_MODULE() - (dispatch_queue_t)methodQueue @@ -56,6 +60,7 @@ + (BOOL)application:(UIApplication *)app openURL:(NSURL *)URL options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options { + lastDispatchedLink = URL; postNotificationWithURL(URL, self); return YES; } @@ -167,6 +172,9 @@ - (void)handleOpenURLNotification:(NSNotification *)notification self.bridge.launchOptions[UIApplicationLaunchOptionsUserActivityDictionaryKey]; if ([userActivityDictionary[UIApplicationLaunchOptionsUserActivityTypeKey] isEqual:NSUserActivityTypeBrowsingWeb]) { initialURL = ((NSUserActivity *)userActivityDictionary[@"UIApplicationLaunchOptionsUserActivityKey"]).webpageURL; + } else if (initialURL == nil && lastDispatchedLink != nil) { + initialURL = lastDispatchedLink; + lastDispatchedLink = nil; } } resolve(RCTNullIfNil(initialURL.absoluteString));