Facebook single sign on in iOS issue - ios

I just run the demo app for the single sign on Facebook and I am getting the following:
And what I want is actually something like this:
I wanted it to not show as a web view, how do I do that?

Please see my answer here (which answers this question):
FaceBook API, login in-app
Please also note my caveat. OAuth was designed to authenticate outside of your application - but in this case, you can make it work inside (but it breaks a core principle of OAuth).

When an app requests authorization or login, the application gets the user's login information via the browser (as you showed in the second image) or, if you have the Facebook app installed, from the Facebook app. It looks like you have the Facebook app installed, so the app automatically pulled the user's information from that app.
Then, for any new app that a user uses, Facebook verifies with the user that the app's requested features are allowed by the user.
Since your device pulled the login info from the Facebook app, the email/password screen is not used and the permissions screen is shown first. Once you allow the features, you should not see that screen again, when you start the app again for that same user.

Modify your Facebook.m
- (void)authorize:(NSArray *)permissions {
self.permissions = permissions;
// with both options NO, authorization always happens in-app
[self authorizeWithFBAppAuth:NO safariAuth:NO];
}

Related

How to know user has already done Facebook login at iOS app

I am developing iOS App which use Facebook iOS SDK 4.
When user has already done Facebook login, by doing Facebook login the dialog which shows "user has already approved your app" had be displayed.
So, do not show the dialog. I want to know whether the user has already done Facebook login.
Anyone know the good way? I think accessToken is returned if user once had done Facebook login.
FBSDKAccessToken manage current logged user's accessToken.
According to official Facebook Login guide
"FBSDKAccessToken Represents the access token provided by a successful login. Most important, it provides a global +currentAccessToken to represent the currently logged in user."
The currentAccessToken is a convenient representation of the token of the current user and is used by other SDK components (like FBSDKLoginManager).
According to above you can check either user has valid accessToken or not and based on this you can track call login method otherwise just skip to next flow.
In Facebook the access tokens are per user so you can pass them around apps and they will work. In your case if you can ship an access token from another app you will be able to skip the next logging in and use the API normally.
However I think this this thread will help you.
Things are a little bit different with iOS cause I have done a facebook login on Android and got no such issues.

facebook iphone - how login under different user

I'm making a game for iphone, so my question:
How is the end user supposed to change his login. Meaning if he decides to log in under a different name?
I noticed that even a resetting of the phone and reinstalling the app doesn't work, I'm still logged in under the same user as before.
My next guess was FB.Logout, but this page tells me not to use it:
https://developers.facebook.com/docs/unity/reference/current/FB.Logout
And also, under Settings -> Facebook I logged into another user already, too - in my game it's still using the old user...
You need to set
[FBSession.activeSession closeAndClearTokenInformation];
for Facebook Logout.
closeAndClearTokenInformation closes the session and clears any cached info, destroying the session. This means that when the app is re-launched the cached token will not be available. The login view will then be shown.
That is because that LogOut function will log out the user from FACEBOOK, not just from your app. Plus the documentation you are looking at is for unity. You should follow this guide: https://developers.facebook.com/docs/facebook-login/ios/v2.0
They show how you can easily log in and log out which is what you are looking for. If you don't have a predefined account set on the device then you will be able to log in with your email and password using the facebook log in interface (in were you can log in as a different user if you want)

How to login to application using user's Twitter account?

How can I create a login page where a user can login using their twitter identity.
I am running iOS7, So I have created a single page app.
I have added Social framework and added
#import <Social/Social.h>
I am wanting to keep the application as streamline as possible so when the application first loads, and loads each time there after I am checking if the user is signed into the app if not then I would like them to sign in using their twitter account.
I will check this here in the app delegate
- (void)applicationDidBecomeActive:(UIApplication *)application
However, I don't know how to sign in using Twitter.
Everything out there at the moment is focused around posting things to Twitter, I don't care about any of that. I want to know about using Twitter to sign into your app. and then what ever relevant issues I need to know. What data should I store to check when the user loads the app in the future etc.
You can follow following tutorial for twitter integration using user account.
http://www.techotopia.com/index.php/An_iOS_7_Twitter_Integration_Tutorial_using_SLRequest
if do you want to make custom twitter login than you can follow following url
http://codegerms.com/login-with-twitter-example-with-ios-tutorial-using-oauth/
Follow these two tutorial
First get access token, for getting access token follow the following tutorial.
http://codegerms.com/login-with-twitter-example-with-ios-tutorial-using-oauth/
Then using access token get account details, for getting account details follow following tutorial
http://codegerms.com/get-user-info-data-twitter-api-example-ios-objective-c/

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

Resources