I’ve been trying to open Facebook page using React Native Linking API. It doesn’t work for me. I do have Facebook app installed. Here is what I tried:
Linking.openURL('fb://page/<page_name>');
Linking.openURL('fb://profile/<profile_name>');
Linking.openURL('http://facebook.com/<page_name>');
I also tried to use Communications library: Communications.web(url)
. None works for Facebook and Instagram. However it works like a charm for Google Maps, Apple Maps, Twitter and other big guys.
I was wondering if I was doing something wrong or maybe we should send some Android articles to those people from Facebook on how to properly implement deep linking in their apps? They clearly don’t know what they are doing.
7
Answers
Ok, found one way to open Facebook:
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:You can also do this in your Xcode project in
info.plist
.I’m having the same issue, but not able to solve it. I have multiple social networking buttons with the
onpress
action ofonPress= {()=> 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 asonPress= {()=> 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:“`
“`
The above code doesn’t work as intended, but nothing else seems to.
Update – May 2019
Nothing here worked for me, but with some random tryings, i found this solution working :
And if you are looking for your pageid, here’s a little tutorial :
https://roadtoblogging.com/get-facebook-page-id/
According to the docs https://reactnative.dev/docs/linking#canopenurl. Promise can be rejected for android. This is my approach to handle this for iOS and android
Worked for me using these :
Also, don’t forget to add equivalent attributes in Info.plist for apps to be allowed, as: