Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deep link not working if my app is in the background #22509

Closed
3 tasks done
nicomontanari opened this issue Dec 4, 2018 · 5 comments
Closed
3 tasks done

Deep link not working if my app is in the background #22509

nicomontanari opened this issue Dec 4, 2018 · 5 comments
Labels
Ran Commands One of our bots successfully processed a command. Resolution: For Stack Overflow A question for Stack Overflow. Applying this label will cause issue to be closed. Resolution: Locked This issue was locked by the bot.

Comments

@nicomontanari
Copy link

nicomontanari commented Dec 4, 2018

Environment

React Native Environment Info:
System:
OS: macOS 10.14.1
CPU: x64 Intel(R) Core(TM) i5-7500 CPU @ 3.40GHz
Memory: 732.00 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.12.0 - /usr/local/bin/node
Yarn: 1.10.1 - /usr/local/bin/yarn
npm: 6.4.1 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
IDEs:
Android Studio: 3.2 AI-181.5540.7.32.5056338
Xcode: 10.1/10B61 - /usr/bin/xcodebuild
npmPackages:
@types/react: 16.7.8 => 16.7.8
@types/react-native: 0.57.15 => 0.57.15
react: 16.6.3 => 16.6.3
react-native: 0.57.7 => 0.57.7
npmGlobalPackages:
create-react-native-app: 1.0.0

Description

I use universal link, when my app is close deep link works fine....but if my app is in the background it opens but it doesn't get the url

Reproducible Demo

componentDidMount() {
    Linking.getInitialURL().then(url => {
        if (url !== null)
            this.navigateFromUrl(url)
    })

    if (Platform.OS === 'ios') {
        Linking.addEventListener('url', this.handleOpenURL)
    }
}

componentWillUnmount() {
    if (Platform.OS === 'ios')
        Linking.removeEventListener('url', this.handleOpenURL)
}

handleOpenURL = (event) => {
    this.navigateFromUrl(event.url)
}

navigateFromUrl = (url) => {
    const { navigate } = this.props.navigation
    const route = url.replace(/.*?:\/\//g, '')
    const id = parseInt(route.match(/\/([^\/]+)\/?$/)[1], 10)
    const routeName = route.split('/')[1].toString()

    switch (routeName) {
        case 'product':
            navigate({
                routeName: 'ProductPage',
                params: { product: id }
            })
            break
        case 'store':
            navigate({
                routeName: 'StorePage',
                params: { store: id }
            })
            break
        case 'order':
            navigate({
                routeName: 'FullPageOrder',
                params: { orderId: id }
            })
            break
    }
}
@react-native-bot
Copy link
Collaborator

Can you run react-native info and edit your issue to include these results under the Environment section?

If you believe this information is irrelevant to the reported issue, you may write [skip envinfo] under Environment to let us know.

@hramos hramos added the Resolution: For Stack Overflow A question for Stack Overflow. Applying this label will cause issue to be closed. label Dec 5, 2018
@react-native-bot react-native-bot added the Ran Commands One of our bots successfully processed a command. label Dec 5, 2018
@react-native-bot
Copy link
Collaborator

Please use Stack Overflow for this type of question.

@glocore
Copy link

glocore commented May 8, 2019

@nicomontanari98 were you able to solve for this?

@nicomontanari
Copy link
Author

@platonish Unfortunately no

@glocore
Copy link

glocore commented May 14, 2019

See this

@facebook facebook locked as resolved and limited conversation to collaborators Dec 5, 2019
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Dec 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Ran Commands One of our bots successfully processed a command. Resolution: For Stack Overflow A question for Stack Overflow. Applying this label will cause issue to be closed. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

4 participants