由FacebookUID Swift开放Facebook个人资料 [英] Swift Open Facebook Profile by FacebookUID

查看:252
本文介绍了由FacebookUID Swift开放Facebook个人资料的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用他们的Facebook UID在Swift中打开用户的Facebook个人资料。在模拟器中,它起作用并打开了网页版本的配置文件,并且工作正常,但是在我的实际设备上,它会打开Facebook本机应用程序,并给我一个找不到页面错误。

  guard let facebookUID = self.user?.facebookUID else {
return
}

print(FacebookUID )
let fbURLWeb:NSURL = NSURL(string:https://www.facebook.com/\(facebookUID))!
let fbURLID:NSURL = NSURL(string:fb:// profile / \(FacebookUID))!

if(UIApplication.sharedApplication()。canOpenURL(fbURLID)){
// FB安装
UIApplication.sharedApplication()。openURL(fbURLID)
} else {
// FB未安装,在safari
中打开UIApplication.sharedApplication()。openURL(fbURLWeb)
}



我做错了什么?



提前感谢



编辑



我注意到,如果用户删除或没有在手机上安装Facebook应用程序,它将通过Safari正确打开配置文件,这就是为什么它在模拟器上工作,但没有在我的设备。但是,如果我尝试像 fb:// profile / 4 (这是Mark Zuckerburg的个人资料)的公开个人资料,我也注意到我可以在Facebook应用中工作)。



Facebook ID是应用范围的用户ID,所以你可以使用像

  fb:// profile?app_scoped_user_id =%@ 
pre>

但也可以查看有关 https:/ /developers.facebook.com/bugs/332195860270199 使用



fb:// profile?app_scoped_user_id =%@打开Facebook个人资料



不支持。



所以你必须打开Facebook个人资料在Safari中,您可以在应用程序的Webview中使用用户个人资料。
我已经检查一些Facebook id 10000 **** 889,10000 *** 041等都有开放的个人资料在Facebook应用程序。有些有相同的错误.Page bot发现。



可能是隐私设置 - >您是否希望搜索引擎链接到您的个人资料 - >否。限制搜索。



从Facebook中获取用户的ids窍门:



1)右键单击该人或页面的个人资料照片,选择属性,ID将被包含在页面中



2)在移动浏览中,如果打开照片,
fbid = ***& pid = 1000 .... 89所以1000 .... 89将是您的用户ID


I'm trying to open a user's Facebook profile in Swift using their Facebook UID. In the Simulator, it works and opens up the web version of the profile and works fine, however on my actual device, it opens up the Facebook native app and gives me a "Page not Found" error.

guard let facebookUID = self.user?.facebookUID else {
    return
}

print(facebookUID)
let fbURLWeb: NSURL = NSURL(string: "https://www.facebook.com/\(facebookUID)")!
let fbURLID: NSURL = NSURL(string: "fb://profile/\(facebookUID)")!

if(UIApplication.sharedApplication().canOpenURL(fbURLID)){
    // FB installed
    UIApplication.sharedApplication().openURL(fbURLID)
} else {
    // FB is not installed, open in safari
    UIApplication.sharedApplication().openURL(fbURLWeb)
}

What am I doing wrong?

Thanks in advance!

EDIT

I've noticed that if a user deletes or doesn't have the Facebook app installed on their phone, it will open up the profile correctly through Safari, which is why it worked on the simulator, but didn't on my device. However, I've also noticed I can get it to work in the Facebook app if I try a public profile like fb://profile/4 (which is Mark Zuckerburg's profile).

解决方案

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

这篇关于由FacebookUID Swift开放Facebook个人资料的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆