Linking Native API

Other topics

Outgoing Links

To open a link call openURL.

Linking.openURL(url)
.catch(err => console.error('An error occurred ', err))

The preferred method is to check if any installed app can handle a given URL beforehand.

Linking.canOpenURL(url)
.then(supported => {
  if (!supported) {
    console.log('Unsupported URL: ' + url)
  } else {
    return Linking.openURL(url)
  }
}).catch(err => console.error('An error occurred ', err))

URI Schemes

Target AppExampleReference
Web Browserhttps://stackoverflow.com
Phonetel:1-408-555-5555Apple
Mailmailto:[email protected]Apple
SMSsms:1-408-555-1212Apple
Apple Mapshttp://maps.apple.com/?ll=37.484847,-122.148386Apple
Google Mapsgeo:37.7749,-122.4194Google
iTunesSee iTunes Link MakerApple
Facebookfb://profileStack Overflow
YouTubehttp://www.youtube.com/v/oHg5SJYRHA0Apple
Facetimefacetime://[email protected]Apple
iOS Calendarcalshow:514300000 [1]iPhoneDevWiki

[1] Opens the calendar at the stated number of seconds since 1. 1. 2001 (UTC?). For some reason this API is undocumented by Apple.

Incomming Links

You can detect when your app is launched from an external URL.

componentDidMount() {
  const url = Linking.getInitialURL()
  .then((url) => {
    if (url) {
      console.log('Initial url is: ' + url)
    }
  }).catch(err => console.error('An error occurred ', err))
}

To enable this on iOS Link RCTLinking to your project.

To enable this on Android, follow these steps.

Contributors

Topic Id: 9687

Example Ids: 29886,29887

This site is not affiliated with any of the contributors.