- Start Date: 2018/07/13
- RFC PR:
- React Navigation Issue:
Add a navigateToURL method to the API. Allows users to navigate just like Linking.openURL does internally without using Linking.openURL.
compose(
withNavigation,
withHandlers({
onDynamicLinkReceived: ({
navigation,
}) => link => {
navigation.navigateToURL(link) // navigates within the app as if `Linking.openURL` was called
}
})
)
Currently the recommended approach to navigating with a full URL is to use Linking.openURL.
There are downsides to using this approach. If we are already in the app, calling Linking.openURL may trigger user
approval to continue using the app to handle the link:
Consider the following use case using Firebase dynamic links:
- User receives an SMS with a dynamic link like
https://example.page.link/xxxand clicks it - The user has never clicked a link for
https://example.page.linkthat before and Android prompts them which application to open the link with - The user chooses to open
https://example.page.link/xxxin our app - The application received the dynamic link and using Firebase API can retrieve the link
https://example.com/xxx. The application now must route the user to the appropriate path/xxxin the application. Using the recommended approach the application callsLinking.openURL('https://example.com/xxx') - The user has never clicked a link for
https://example.combefore and Android prompts them which application to open the link with (again) - The user is probably confused why they were asked twice after they clicked only one link. They may feel uncertain about what to do
It is also more performant to directly route to a URL instead of using Linking.openURL.
I think adding we should add navigateToURL function to the navigation property API. This would not be a breaking change--simply exposing existing functionality that is implemented here.
Proposed implementation here
- More API surface area to maintain
- Encourages using deeplinking/paths which already have issues logged against them
To avoid the situation described above, the user (of react-navigation) can try to parse the URL themselves to determine the route and navigate via existing API calls.
We will document the new API on the website. This should not be a breaking change.
We should recommend users use this API to navigate to deep links. We should recomment Linking.openURL only for external URLs. We will document the new API on the website.
- Should there be a navigation action for this?
