0

My goal is to allow users share content from the application to external world (for example Viber, Whats App etc)

Here is the code:

import {Share} from 'react-native'

Share.share({ message:  'appscheme://feeds/:feedId'})

However this link is not clickable hence is useless since cannot open the app

What about Share.share({ message: 'https://appscheme.com/feeds/:feedId'})

My goal is to achieve the same behavior as YouTube video sharing. You can press on video share, send it to anybody in chat, and then to access it right from there. For example:

enter image description here

Than you in advance!

spatak
  • 1,039
  • 1
  • 14
  • 25
  • do you want them to get a `link` that leads to your website/app? – jted95 Nov 18 '21 at 19:46
  • I want to be able to share a clickable link which redirects to the react native app – spatak Nov 18 '21 at 21:19
  • can you share your linking config? You need to add prefixes to your linking so the device will be able to redirect to your app if one of the prefixes detected. – jted95 Nov 18 '21 at 22:30

1 Answers1

1

That is called universal link(iOS) / App Links (Android)

FYR: https://reactnative.dev/docs/linking#open-links-and-deep-links-universal-links

Getting the link opening your app:

function handleURL(url) {
    // your stuff
}

useEffect(() => {
    function addLinkingEventListener() {
        Linking.addEventListener('url', evt => {
            handleURL(evt?.url)
        })
    }

    Linking.getInitialURL()
        .then(initUrl => {
            handleURL
        })
        .catch(handleError)
        .finally(() => {
            addLinkingEventListener()
        })

    return () => {
        Linking.removeEventListener('url', handleUrlEvent)
    }
}, [])
Horst
  • 1,733
  • 15
  • 20