How to create React Native button that redirects to a social networking page

Asked

Viewed 85 times

0

I need to create social network buttons inside my app to redirect to the page in question.

Example:

By clicking the facebook icon button I will stop at the page in question through the URL by opening the browser or the facebook app.

1 answer

0


You can use the native method Linking react Native!

Example:

import { Linking, ToastAndroid } from 'react-native'

const openUrl = async(url) => {
  if(await Linking.canOpenURL(url)) {
    await Linking.openURL(url)
  }
  else {
    ToastAndroid.show('Can\'t open this URL', ToastAndroid.SHORT)
  }
}

Now just implement this function within the function onPress from the button, passing the link you want as argument.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.