Skip to content

Instantly share code, notes, and snippets.

@coproduto
Last active July 7, 2021 23:31
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coproduto/516f9e754d9c6feed8922c0c345c595a to your computer and use it in GitHub Desktop.
Save coproduto/516f9e754d9c6feed8922c0c345c595a to your computer and use it in GitHub Desktop.
// React Native
if (Linking.canOpenURL(myURL)) {
Linking.openURL(myURL);
} else {
// handle app not available
}
// Android
val uriIntent = Uri.parse(myUrl).let { url -> Intent(INTENT_TYPE, url) }
try {
startActivity(intent)
} catch (e: ActivityNotFoundException) {
// handle app not available
}
// iOS
if UIApplication.canOpenURL(myURL) {
UIApplication.open(myURL)
} else {
// handle app not available
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment