Allow navigation to URI in Wilde via Flipper

Summary:
Here I add functionality to Wilde that allows navigation to internal deeplinks via Flipper. I beleive this was once a feature by allowing access to non whitelisted URL's but this has since been removed.

The Flipper plugin can now receive a navigate_to command which then emits a url over the navigateTo socket. This is picked up by the FBNavigationFlipperLogger plugin where it gets an instance of the NavigationCoordinator and opens the url.

Reviewed By: kolinkrewinkel

Differential Revision: D17282530

fbshipit-source-id: 0ba29aeac2a32d5464e8fa1dfa4e53af7cf94159
This commit is contained in:
Daniel Büchele
2019-09-23 06:39:17 -07:00
committed by Facebook Github Bot
parent 976101449d
commit 4e5ede6d37

View File

@@ -124,14 +124,20 @@ export default class extends FlipperPlugin<State, any, PersistedState> {
});
};
navigateTo = (query: string) => {
navigateTo = async (query: string) => {
const filteredQuery = filterOptionalParameters(query);
this.props.setPersistedState({currentURI: filteredQuery});
const requiredParameters = getRequiredParameters(filteredQuery);
if (requiredParameters.length === 0) {
this.getDevice().then(device => {
const device = await this.getDevice();
if (this.realClient.query.app === 'Facebook' && device.os === 'iOS') {
// use custom navigate_to event for Wilde
this.client.send('navigate_to', {
url: filterOptionalParameters(filteredQuery),
});
} else {
device.navigateToLocation(filterOptionalParameters(filteredQuery));
});
}
} else {
this.setState({
requiredParameters,