React Native open Facebook page
I'm having the same issue, but not able to solve it. I have multiple social networking buttons with the onpress
action of onPress= {()=> Linking.openURL("https://www.SOME_SOCIAL.NETWORK")}
My buttons linking to Twitter, Instagram, and SnapChat all open the app if installed or a web page in Safari if the app is not installed. The only outlier is Facebook. Given an onpress action such as onPress= {()=> Linking.openURL("https://www.facebook.com/")}
the link will always open in Safari even if the app is installed.
Because of this odd behavior I'm handling my onpress
action for the Facebook link like this:
```
Linking.canOpenURL("fb://profile/XXXXXX").then(supported => {
if (supported) {
return Linking.openURL("fb://profile/XXXXXX");
} else {
return Linking.openURL("https://www.facebook.com/");
}
})
```
The above code doesn't work as intended, but nothing else seems to.
Update - May 2019
// open via app
fb://facewebmodal/f?href=PAGE_NAME
In general, you should check Linking.canOpenURL()
for iOS before trying to open them.
Also, make sure you add your protocols as an array in info.plist
as:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fb</string>
</array>
You can also do this in your Xcode project in info.plist
.
Ok, found one way to open Facebook:
Linking.openURL('fb://page/PAGE_ID');
Linking.openURL('http://instagram.com/_u/USER_NAME');
Linking.openURL('http://instagram.com/_p/PICTURE');