简体   繁体   English

通过iOS中的Facebook SDK通过应用程序登录Facebook?

[英]Facebook login through application through Facebook SDK in iOS?

I am currently integrating Facebook login through the Facebook SDK in iOS. 我目前正在通过iOS中的Facebook SDK集成Facebook登录。 So if i am currently having Facebook application installed in iOS, so if i login through Facebook in my application it should follow the under mentioned scenarios: 因此,如果我当前在iOS中安装了Facebook应用程序,那么如果我在应用程序中通过Facebook登录,则应遵循以下提到的方案:

1) If the Facebook application is already installed then while clicking the Facebook login, the Facebook application should pop up. 1)如果已经安装了Facebook应用程序,则在单击Facebook登录名的同时应弹出Facebook应用程序。

2) Else if we don't have Facebook application it should divert to the web browser. 2)否则,如果我们没有Facebook应用程序,则应将其转移到Web浏览器。

How to do this . 这个怎么做 。 Is it by manually through our coding or Facebook SDK manages it? 是通过我们的编码手动进行还是由Facebook SDK管理?

We can check we have a Facebook application or not. 我们可以检查是否有Facebook应用程序。 But if you redirect the user to Facebook app, then there will not any login page in the FB app. 但是,如果将用户重定向到Facebook应用程序,则FB应用程序中将没有任何登录页面。 Because Facebook .native for loginBehavior uses Safari to open user login. 因为Facebook .native用于loginBehavior使用Safari来打开用户登录。

In that Safari browser, you will have one option to open in the app . 在该Safari浏览器中,您将可以在应用程序中打开一个选项。 The user can either click on that and authorise in-app itself or just go by writing credentials on safari. 用户可以单击它并自己进行应用内授权,也可以通过在野生动物园中编写凭据来进行访问。

Update: 更新:

We can check Whether the user has installed a Facebook app or not with URI Scheme. 我们可以使用URI Scheme检查用户是否已安装Facebook应用程序。 But before that you have to register like this in your info.plist : 但在此之前,您必须像这样在info.plist中进行注册:

Open info.plist as a Source Code like this: 打开info.plist作为源代码,如下所示:

在此处输入图片说明

And paste below code. 并粘贴下面的代码。

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>fb</string>
</array>

Now check like this: 现在检查像这样:

BOOL isFBInstalled = [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"fb://"]]

if (isFBInstalled) { //Check if FB app installed
//Do something
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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