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

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.

Related

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

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.

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.

Permissions dialog in Facebook iOS native app

I'm using Facebook iOS SDK 3.5 to log-in into my app, the following method is invoked:
FBSession openActiveSessionWithReadPermissions
If native iOS login is not enabled and facebook iOS app is installed, the login process will get redirected to the facebook app. The problem is that every single time 'FBSession openActiveSessionWithReadPermissions'is invoked, the facebook app presents the permission dialog to the user, even when the user already authorized the FB app.
The permission list is empty (nil). This problem does not happen if native ios or safari are used to log -in.
Any ideas? Thanks
You can check if the user has successfully logged in by checking for an access token here
Also, you can make sure you aren't popping up a GUI from each call by setting allowLoginUI to false.
+ (BOOL)openActiveSessionWithAllowLoginUI:(BOOL)allowLoginUI;
I've not done any iOS FB stuff myself, but that's what I got from reading the docs.
Also, there seems to be a somewhat related question posted here.

Conflicting errors when login to IOS app using facebook connect

After installing facebook login, we have 2 developers using their own devices (Both using IOS 6.1.2) with conflicting differences.
Developer 1: Clicks facebook login button, and is redirected to URL to enter facebook login/password- then accept permissions. The process works.
Developer 2: Clicks facebook login button, receives permissions dialog in popop (not by url) and does not ask for facebook login/password. The process crashes every time immediately when click (OK) for permissions.
We have spent a great deal of time on this and would appreciate any help!
It sounds to me like Developer 2 has logged into FB in iOS settings, while Developer 1 has not.
That would explain the difference in the login process, though I can't say why iOS-driven FB login would crash but Safari-driven login would not.

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

Resources