Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I open the Facebook App (to a specific page) from React Native Linking?

Linking.openURL('https://www.facebook.com/walmart')
Linking.openURL('fb://profile/walmart');
Linking.openURL('fb://page/walmart');
Linking.openURL('fb://facewebmodal/f?href=walmart')
Linking.openURL('https://www.facebook.com/n/?walmart');

I've tried all of these but all open the web page instead of the app. fb:// opens the app, but doesn't go to the specific page.

React-native 0.61.1

<key>LSApplicationQueriesSchemes</key>
    <array>
        <string>fb</string>
        <string>instagram</string>
        <string>twitter</string>
        <string>whatsapp</string>
        <string>linkedin</string>
        <string>fbapi20130214</string>
        <string>fbapi20130410</string>
        <string>fbapi20130702</string>
        <string>fbapi20131010</string>
        <string>fbapi20131219</string>    
        <string>fbapi20140410</string>
        <string>fbapi20140116</string>
        <string>fbapi20150313</string>
        <string>fbapi20150629</string>
        <string>fbapi20160328</string> 
        <string>fbauth</string>
        <string>fbauth2</string>
        <string>fb-messenger-api20140430</string>
    </array>
like image 881
TIMEX Avatar asked Dec 31 '22 15:12

TIMEX


1 Answers

In order to open a specific facebook page in the facebook app, you need to have the unique identifier (PAGEID).

How to get the PAGEID?

Option 1: Use some third party service like for example: https://findmyfbid.com/. Here you can just enter the facebook url of the page.

Option 2: Open the facebook url of the page in your browser, perform a right click on the profile image, and press COPY LINK ADDRESS.

Walmart's profile image address is:

www.facebook.com/159616034235/photos/10157225802004236/ The PAGEID is highlighted.

How to open the page in the FB App?

On iOS Devices: fb://profile/PAGEID

On Android Devices: fb://page/PAGEID

CODE EXAMPLE:

const pageID = 159616034235; // Waltmart's ID 
const scheme = Platform.select({ ios: 'fb://profile/', android: 'fb://page/' });

const url = `${scheme}${pageID}`;

and then you can use:

Linking.openURL(url);
like image 90
Tim Avatar answered Jan 05 '23 15:01

Tim