简体   繁体   中英

Facebook login through application through Facebook SDK in iOS?

I am currently integrating Facebook login through the Facebook SDK in iOS. 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:

1) If the Facebook application is already installed then while clicking the Facebook login, the Facebook application should pop up.

2) Else if we don't have Facebook application it should divert to the web browser.

How to do this . Is it by manually through our coding or Facebook SDK manages it?

We can check we have a Facebook application or not. But if you redirect the user to Facebook app, then there will not any login page in the FB app. Because Facebook .native for loginBehavior uses Safari to open user login.

In that Safari browser, you will have one option to open in the app . 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. But before that you have to register like this in your info.plist :

Open info.plist as a Source Code like this:

在此处输入图片说明

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
}

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