Skip to content

Instantly share code, notes, and snippets.

@SudoPlz
Created October 23, 2023 17:59
Show Gist options
  • Select an option

  • Save SudoPlz/003d1f70a68034d5a9639d2d0dfca413 to your computer and use it in GitHub Desktop.

Select an option

Save SudoPlz/003d1f70a68034d5a9639d2d0dfca413 to your computer and use it in GitHub Desktop.

Revisions

  1. SudoPlz created this gist Oct 23, 2023.
    42 changes: 42 additions & 0 deletions react-native.patch
    Original 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));