0

I want to add my social media links on my app. But when I add them with url, they are opening on browser. When I use facebook:// system, It doesnt work on Android.

I want my URL's to work as "if app is exist, then open it on app."

That doesnt work on Android:

import * as Linking from 'expo-linking'

          <TouchableOpacity style={[styles.iconButton, { backgroundColor: '#3b5998' }]} onPress={() => Linking.openURL('fb://page/blablabla')}>
            <FontAwesome name="facebook" size={26} color="#fff" />
          </TouchableOpacity>

That doesnt open URL's on their native app:

          <TouchableOpacity style={[styles.iconButton, { backgroundColor: '#3b5998' }]} onPress={() => Linking.openURL('https://www.facebook.com/blablabla')}>
            <FontAwesome name="facebook" size={26} color="#fff" />
          </TouchableOpacity>
TCS
  • 629
  • 3
  • 11
  • 32
  • 1
    Does this answer your question? [React Native open Facebook page](https://stackoverflow.com/questions/46616348/react-native-open-facebook-page) You can check with `Linking.canOpenURL()` if user has the app and fallback to url if it doesnt. https://roadtoblogging.com/get-facebook-page-id/ – Ugur Eren Jul 30 '21 at 06:01

1 Answers1

0

this is how you can open link.

import { View, Text, Image, Linking, TouchableOpacity} from 'react-native'


<TouchableOpacity style={{ marginVertical: 5 }} onPress={()=>{ Linking.openURL(item.link)}}>
   <Text style={{ alignSelf: 'center', color: '#2575FC' }}>
       Click here to read more
   </Text>
</TouchableOpacity>
Engr.Aftab Ufaq
  • 3,356
  • 3
  • 21
  • 47