Swift Open Facebook Profile by FacebookUID

Hi based on documentation Facebook ID is the App-scoped User ID so you can use like

fb://profile?app_scoped_user_id=%@

But also check bug report on https://developers.facebook.com/bugs/332195860270199 opening the Facebook profile with

fb://profile?app_scoped_user_id=%@

is not supported.

So you will have to open the Facebook profile within Safari or you can use in app webview to open user profile. I have check with some facebook id 10000****889,10000***041 etc. all have open profile in facebook app.Yes some have same error.Page bot found.

May be there is Privacy setting->Do you want search engine outside link to your profile->No. restrict search.

To get ids of user from facebook Trick :

1)Right click on the person or page's profile photo, select properties and the ID will be included in the page

2)In mobile browswe if you open photo there is id E.g. " fbid = *** & pid = 1000....89 " so 1000....89 will be your user id


Here is another solution that works for iOS 10 & Swift 3.

First of all, you should add LSApplicationQueriesSchemes key to Info.plist file. If you do not add this key, canOpenURL will always return false. Than you need to add what scheme(s) you want to check. Use fb for facebook.

It should looks like this:

enter image description here

The rest is Swift:

if UIApplication.shared.canOpenURL(URL(string: "fb://profile/PROFILE_ID")!) {
    UIApplication.shared.open(URL(string: "fb://profile/PROFILE_ID")!, options: [:])
} else {
    UIApplication.shared.open(URL(string: "https://facebook.com/PROFILE_ID")!, options: [:])
}

Note: Replace PROFILE_ID with your target.


Thanks to vien vu. From iOS 9 < above, You must whitelist the url's that your app will call out to using the LSApplicationQueriesSchemes key in your Info.plist. So add this code to your plist file:

 <key>LSApplicationQueriesSchemes</key>
<array>
<string>fb</string>
<string>fbapi</string>
<string>fbauth2</string>
<string>fbshareextension</string>
<string>fb-messenger-api</string>
<string>twitter</string>
<string>whatsapp</string>
<string>wechat</string>
<string>line</string>
<string>instagram</string>
<string>kakaotalk</string>
<string>mqq</string>
<string>vk</string>
<string>comgooglemaps</string>
</array>