Skip to content

Instantly share code, notes, and snippets.

@pbojinov
Created May 3, 2016 00:25
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pbojinov/e51d1f1c55bd8b7fc596725b62e1aed8 to your computer and use it in GitHub Desktop.
Save pbojinov/e51d1f1c55bd8b7fc596725b62e1aed8 to your computer and use it in GitHub Desktop.
React Native App with Deep Link Support
import React, { View, Text, Linking } from 'react-native';
import urlParse from 'url-parse';
class App extends Component {
componentDidMount() {
// Handling Deep Linking
const deepLinkUrl = Linking.getInitialURL().then((url) => {
console.log(`Deep Link URL: ${url}`);
if (url) {
const parsedUrl = urlParse(url, true);
const {query: {userId}} = parsedUrl;
// if user id query param exists, lets load that user's profile
if (userId) {
this._loadUserProfile(userId);
}
}
}).catch(err => console.error('An error occurred', err));
}
_loadUserProfile() {
// ..do something
}
render() {
return (
<View>
<Text>Hello World</Text>
</View>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment