Skip to content

Instantly share code, notes, and snippets.

@naishe
Created December 6, 2020 09:46
Show Gist options
  • Save naishe/46dfb1e23612398e4bd525f03c001dd9 to your computer and use it in GitHub Desktop.
Save naishe/46dfb1e23612398e4bd525f03c001dd9 to your computer and use it in GitHub Desktop.
Deep Linking Push Notifications with React Navigation #5
// App.tsx
// only new changes shown, refer: https://gist.github.com/naishe/da4830b72eeb81f8a5e29b6e45692d86
const linking: LinkingOptions = {
prefixes: ['myapp://', 'https://app.myapp.com'],
config: deepLinksConf,
async getInitialURL() {
// Check if app was opened from a deep link
const url = await Linking.getInitialURL();
if (url != null) {
return url;
}
// Check if there is an initial firebase notification
const message = await messaging().getInitialNotification();
// Get deep link from data
// if this is undefined, the app will open the default/home page
return message?.data?.link;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment