Created
December 6, 2020 09:46
-
-
Save naishe/46dfb1e23612398e4bd525f03c001dd9 to your computer and use it in GitHub Desktop.
Deep Linking Push Notifications with React Navigation #5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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