在 iOS 上通过本机 Facebook 应用打开 Facebook 链接 [英] Open a facebook link by native Facebook app on iOS
问题描述
如果本机 Facebook 应用程序安装在 iPhone 上.如何从我的应用程序打开一个 facebook 链接到本机 Facebook 应用程序.在Safari打开的情况下,链接同:
<块引用>http://www.facebook.com/AlibabaUS
谢谢.
以下是 Facebook 应用使用的一些方案,源链接上还有更多方案:
示例
NSURL *url = [NSURL URLWithString:@"fb://profile/<id>"];[[UIApplication sharedApplication] openURL:url];
方案
<块引用>fb://profile – 打开 Facebook 应用到用户的个人资料
fb://friends – 打开 Facebook 应用到好友列表
fb://notifications – 打开 Facebook 应用到通知列表 (注意:此 URL 似乎存在错误.通知页面打开.但是,无法导航到 Facebook 中的其他任何位置应用)
fb://feed – 打开 Facebook 应用到新闻提要
fb://events – 打开 Facebook 应用到活动页面
fb://requests – 打开 Facebook 应用到请求列表
fb://notes – 打开 Facebook 应用到备注页面
fb://albums – 打开 Facebook 应用到相册列表
如果在打开此 url 之前您想检查用户是否使用 facebook 应用程序,您可以执行以下操作(如下面的另一个答案所述):
if ([[UIApplication sharedApplication] canOpenURL:nsurl]){[[UIApplication sharedApplication] openURL:nsurl];}别的 {//像往常一样打开url}
来源
http://wiki.akosma.com/IPhone_URL_Schemes#Facebook
If the native Facebook app is installed on the iPhone. How do I open a facebook link into the native Facebook app from my app. In the case of opening by Safari, the link is same as:
Thank you.
Here are some schemes the Facebook app uses, there are a ton more on the source link:
Example
NSURL *url = [NSURL URLWithString:@"fb://profile/<id>"];
[[UIApplication sharedApplication] openURL:url];
Schemes
fb://profile – Open Facebook app to the user’s profile
fb://friends – Open Facebook app to the friends list
fb://notifications – Open Facebook app to the notifications list (NOTE: there appears to be a bug with this URL. The Notifications page opens. However, it’s not possible to navigate to anywhere else in the Facebook app)
fb://feed – Open Facebook app to the News Feed
fb://events – Open Facebook app to the Events page
fb://requests – Open Facebook app to the Requests list
fb://notes – Open Facebook app to the Notes page
fb://albums – Open Facebook app to Photo Albums list
If before opening this url you want to check wether the user fas the facebook app you can do the following (as explained in another answer below):
if ([[UIApplication sharedApplication] canOpenURL:nsurl]){
[[UIApplication sharedApplication] openURL:nsurl];
}
else {
//Open the url as usual
}
Source
http://wiki.akosma.com/IPhone_URL_Schemes#Facebook
这篇关于在 iOS 上通过本机 Facebook 应用打开 Facebook 链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!