How to log out of Facebook when using a custom login button, on iOS using FBSDKLoginKit? - ios

I am implementing a custom login button in my iOS app, using the FBSDKLoginKit CocoaPod, version 4.8.0. I already have log in working, but I can't figure out how to log out of Facebook. I am already calling logOut on an instance of FBSDKLoginManager, but that only seems to clear the currentAccessToken value. When I tap my login button again, I see a screen that looks like this:
I want to be able to log in as a different Facebook user. How can I achieve this?

In the new version of the Facebook iOS SDK (4.6 and above, I think) the default behaviour of login uses Safari View Controller. So if you are logged into Safari and have already logged into your app using Facebook, it will not ask for your credentials again and show you that screen. If you want to log in as a different user, then you will need to log out of Facebook in Safari in which case the login dialog should ask for your credentials. Also, you can remove the app from your app settings and try to login in which case it will show you the permissions screen. This behaviour of the login dialog probably follows from the best practices where a logout from an app should not cause logout from Facebook itself.

Related

Twitter login page comes up even though user denies to give access to Twitter from App

When I am trying to login to my App in iOS 11 using Twitter, sometimes I am getting an alertview-style popup saying “ wants to open twitter”, with the options "cancel" and "open". If I tap on "open", it is the normal login flow for twitter.
However, if I tap on cancel, then what I want is for the whole login attempt to be cancelled. Instead, the app redirects me to the webview which opens twitter login page and again I need to cancel that dismiss the page saying “Error during login”. Could anyone able to simulate it?
Looks like it might be related to a known issue that Twitter is trying to fix? See https://twittercommunity.com/t/bug-twitter-kit-ios-3-0-4-login-sometimes-fails-to-redirect-back-to-host-app/89618/24

Facebook Login with another account from iOS app

I'm developing an iOS app that integrates with Facebook SDK. When I make the login for the first time with my facebook account it takes the following steps:
Jump to safari web login
Insert my credentials
After that I authorize the permissions that are requested
And then I go to the main menu of my application.
When I press the logout button, I run the following code:
- (void)logout {
[FBSession.activeSession closeAndClearTokenInformation];
}
With this code I can invalidate the session and clear the access token information. However, when i try to login again, my application jumps to safari web login and my account appears already as logged in (next picture).
If I want to login with another Facebook account, i can't do it. In other words, I would like to follow the steps that I said earlier or have a mechanism like "Not you?" that Facebook official app provides.
Any idea that what I have to do?
You're still logged in through Safari. Log out there (or clear your cache).
wrong, happens when not logged in safari and FB app.

Facebook iOS SDK and Safari based authentication issue

I have used latest FB SKD in my iOS app so users can use facebook account to login. Application open the FB app and comes back to my app perfectly fine. However, in some place in the app, i have to show/pull some people facebook page (safari based using WebView), but even user already used the Facebook account to login into my native ios app, but the page still ask user to login again and when they click login, it shows them the annoying FB username/pass page.
Is there anyway, that the FB safari based page can authenticate the user since it's already logged into my app using FB integration? do i have to include query or something. Please give me details how to solve this problem since i'm new in this..
thanks again for your help...
pic: https://www.dropbox.com/s/rjlptu7ufpcq3vl/fb.png
When the user switches to Facebook app to authenticate, it doesn't create a cookie for your UIWebView which is why it's asking to login again. Have the user authenticate inside the UIWebView without switching to the Facebook app.
What you're talking about also sounds like a similar thing that happens with Facebook dialogs not knowing about the current Facebook session.
If you authenticate your user via Facebook, try saying the Facebook object itself as an instance variable somewhere in memory so you can access it again (a property on a singleton controller, perhaps?).
Spawning dialogs from an authenticated Facebook object appears to let them use the dialog without reauthenticating iff you have a [FBSession activeSession]. So you'd also have to maintain an active FB session. But I'm not sure if this kind of solution will work since you didn't show specific code for how you're doing your web-based FB fetches.
This question might also prove helpful:
Implement Login with Facebook in iOS 5 and 6

Facebook app redirects users to my app and becomes unusable once SSO is done

I'm updating my app to use the Facebook SDK(3.1) and using [FBSession openActiveSessionWithReadPermissions: allowLoginUI: completionHandler:] for authentication.
Authentication works fine like the following:
Open my app and log in, which uses Facebook SSO.
Redirected to the Facebook app.
Redirected back to my app after authentication, and my app can get
an access token and
necessary information as expected. -
But I have a problem after authentication.
The problem occurs as follows:
Close my app after authentication is done.
Open the Facebook app.
The Facebook app shows a blank view with the cancel button on the navigation bar -
The cancel button does not work.
When I scroll down the blank view, the Facebook app redirects to my app.
Here is one way to reproduce the problem:
Install my app and log in, which uses Facebook SSO.
Log out of my app.
Kill the processes of Facebook app and my app running in the background.
Open my app and log in again.
I tested it with the latest Facebook app and the previous one both on iOS5 and iOS6,
and was able to reproduce the problem with all combinations.
I want to solve this issue, but don't know where the problem is.
Is it a bug in the Facebook SDK or the Facebook app, or any problem in my app?
Thanks.

can't switch users for FB connect on iOS

I have FB connect implemented in my app. After battling with the FB app installed on a user's phone, I finally had success forcing the standard FB dialog and bypassing the FB app
(see iOS: Connect to Facebook without leaving the app for authorization)
My new problem is that I cannot seem to switch FB users within the app. When I click the "Login with Facebook" button from within my app, it quickly brings up the FB dialog, dissappears, and always logs me back in with the previous user (meaning I have no way to switch FB users).
I've check both Safari and the FB app, and neither are logged in. Do I have to tell FB to log out the previous user before a new user/pass is prompted?
Thanks
Your implementation probably saves user's access token in NSUserDefaults. If it is so - you just need to delete it from NSUserDefaults any time there is a logout or you're switching users.
Also if needed you are able to deauthorize the user by making a DELETE graph API call to uid/permissions.
hope this helps

Resources