Reputation: 1389
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:
Than you in advance!
Upvotes: 0
Views: 7523
Reputation: 1739
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)
}
}, [])
Upvotes: 1