简体   繁体   中英

Open Facebook page in Native Facebook IOS App via simple URL Sheme issue

there!

I want to open my Facebook Page (not profile) in native IOS Facebook App, using URL Scheme.

I'm testing this feature - on this example fb://profile

It works fine.

But, when i trying to open my Facebook Page - by fb://page/141720395863506

it just redirect me to Facebook app and nothing happens, simply opens the application, and loads news feed.

Please, help me. I can't find any documentation of official facebook developers guide. And have some quistions: Does, Facebook IOS App Url Sheme still support this feature. And that I might be doing wrong in this situation?

Best regards!

I believe I've found a solution... It works currently under facebook ios 5.0.1 for iPhone.. haven't tried it in iPad yet.

The url is fb://profile/132753734806

NOW the important part is that number. That links to one of my clients, Charles Scott. HOWEVER, that's not their FBID or Page ID.. their Page ID is 10150348920319807

so you would think it should be fb://profile/10150348920319807 but that gives me an error.

Here's how you get the correct code.. click on any of your page's photos.. here's an example for my client https://www.facebook.com/photo.php?fbid=10150348920319807&set=a.10150348920314807.356942.132753734806&type=1&theater

if you notice the FBID that does not work follows fbid= in that URL.. the number you WANT is just before the &type=1theater but following that last period. 132753734806 is the correct code to punch in after fb://profile/

I hope that makes some sense... I know zero about code or coding but this was bothering me so much and I knew there was a way.

Now, the two questions I would love to have answered/working.. 1. if this could work on android phones 2. create a working qr code for this url so people can scan with ios devices and have it open automatically

Good luck and I hope this helps everyone!

The above answer by Alessandro is correct, but that didn't really worked for me.. So this is the proper method. I had a URL https://www.facebook.com/pageName Now, go to: http://findmyfacebookid.com Paste your URL, get Facebook id, and then make url as @"fb://profile/pageID"

IT WORKED FOR ME!

NOTE : Put a check if native application is intalled in a device, else open it through default browser.

 if (![[UIApplication sharedApplication] openURL: [NSURL URLWithString:@"fb://profile/pageId"]]) 
{            
   NSURL *url = [NSURL URLWithString:@"https://www.facebook.com/pageName"];
   [[UIApplication sharedApplication] openURL:url];
}

Swift 3.0 / iOS10:

let fbUrl: NSURL = NSURL(string: "fb://profile/55555555555555")!
let fbWebUrl: NSURL = NSURL(string: "https://facebook.com/yourFacebookPageName")!

if (UIApplication.shared.canOpenURL(fbUrl as URL)) {
    if #available(iOS 10.0, *) {
        UIApplication.shared.open(fbUrl as URL, options: [:], completionHandler: nil)
    } else {
        // Fallback on earlier versions
        UIApplication.shared.openURL(fbUrl as URL)
    }
} else {
    if #available(iOS 10.0, *) {
        UIApplication.shared.open(fbWebUrl as URL, options: [:], completionHandler: nil)
    } else {
        // Fallback on earlier versions
        UIApplication.shared.openURL(fbWebUrl as URL)
    }
}

"55555555555555" should be replaced with the numerical Facebook ID you can get from http://findmyfbid.com and "yourFacebookPageName" with the page's username.

Don't forget to enable the fb url scheme in your app's Info.plist (under LSApplicationQueriesSchemes).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM