-
Notifications
You must be signed in to change notification settings - Fork 24.5k
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
[LinkingIOS] Improve deep linking payload sent to JS on openURL #4955
Conversation
By analyzing the blame information on this pull request, we identified @vjeux, @nicklockwood and @tadeuzagallo to be potential reviewers. |
@@ -76,6 +76,22 @@ var DEVICE_NOTIF_EVENT = 'openURL'; | |||
* } | |||
* ``` | |||
* | |||
* The payload sent to JS in `_handleOpenURL` will be in the following format: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_handleOpenURL
looks like a private method. So I think we should not specify the name.
@satya164 _handleOpenURL is just from the example above, it isn't an internal API or anything. Perhaps I should clear up the wording? |
@arasmussen Oh, didn't notice that. But yeah, the wording can be better. |
Updated, let me know if that's better. |
@arasmussen updated the pull request. |
We should do this processing in JS for x-platform support (see https://facebook.github.io/react-native/docs/intentandroid.html and #4546), or even push it into userspace. |
@ide Ah I see that Android deep linking has similarly formatted URLs. Doing the processing in JS makes sense. Looks like URI.js would work great (besides not parsing out the query params for you). Though I'd argue that since LinkingIOS is iOS only, this change is still net win until we have a more x-platform deep linking module. |
@arasmussen updated the pull request. |
@arasmussen updated the pull request. |
Another interesting tidbit is that |
@arasmussen It turns out that the query param parsing part of NSURLComponents is iOS8+ only, so we can't use it. (I replicated it in only a few lines in RCTUtils though, so maybe it still makes sense to do that part natively if the rest of the code is native?) |
NSURLComponents *urlComponents = [NSURLComponents componentsWithURL:URL | ||
resolvingAgainstBaseURL:NO]; | ||
NSMutableDictionary<NSString *, NSString *> *parameters = [NSMutableDictionary new]; | ||
for (NSURLQueryItem *queryItem in urlComponents.queryItems) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NSURLComponents.queryItems is an iOS8+ api, and we need to support iOS7+ (We got burned by this once already :-))
@arasmussen Any updates on this? |
@nicklockwood Thanks for the feedback, definitely agree. @satya164 Haven't made time for this recently, probably won't be able to for a while. Doesn't seem far from something shippable though. :/ |
@arasmussen updated the pull request. |
@arasmussen updated the pull request. |
Summary: Adds a "Feedback" section which links to feedback.html (which has a Product Pains widget so that people can post, search, and vote on React Native feedback without having to go to productpains.com) Test Plan: Double checked changes in /support.html and that the widget loads (via <iframe>) on /feedback.html.
Don't have time to fix this one up. :/ |
Prior to this commit, just the URL string is sent to JS.
where
This leaves JS to parse the URL when we already have a great parsing
tool (
NSURLComponents
) in iOS from Apple.Test Plan - tested the following URLs
url = 'reactnative://foo.bar/baz?a=b&c=d'
url = 'reactnative://'