what are the differences of various FB login methods? - ios

There are three different login methods in iOS:
Login via web pop-up
Login via Safari
Login via Native App
and one more in iOS 6 - login via native pop-up controller using iOS 6 Facebook credentials.
In my case, I'm using FB comments plugin inside UIWebView and I'd like to allow user to leave comments there. For that I'm using FB login via web pop-up. Using other methods lead to the two different results:
FB comments plugin not loading at all
FB comments plugin loaded, but user is still unauthorized (login via Safari)
Whereas I have no idea, how to deal with the first one, the second one happens I think because cookies (or FB credentials) are stored in safari, but not in my App, which is required for comments plugin to understand that the user has logged in.
In this case, I'm wondering - when and where should we use each of the FB login approaches?
And what should I use in my case?

I recommend using Parse to handle social account management. It's super easy to integrate with your code and free for your purposes. Take a look. Just sign up to Parse, Create an App and follow the easy quickstart guide. They also have great documentation and forums to help you out.

Related

iOS Facebook passwordless login

I have to provide Facebook integration to an app that is mostly hybrid in its design ... i.e, most of the code is written as html5 pages (bundled with the app). I would prefer using the webview method of login to Facebook, but it appears that if I do use the webview method as opposed to using Facebook SDK for iOS, the user will have to enter a password every-time.
Can someone verify if my understanding is correct. This is what is I could gather from https://developers.facebook.com/docs/ios/login-tutorial:
Embedded WebView Login Dialog
...
Advantages:
...
Disadvantages:
Web-based dialogs tend to be slower.
People have to fill in their login credentials every time they go through the login flow.
Special considerations:
...
I created a sample app embedded with Facebook login awhile ago too. Yes, web-based dialogs tend to be slower. However, the user don't have to login their credential every time they go through it. As I tested, the user will just need to enter their info for the first time login only. Nevertheless, the user will need to login when his/her session finish. Please refer to Facebook API docs about how long is the session.
I hope this answer your question somehow. Cheer.

Is it possible to call native ios Facebook login dialog from just a web page (not a web app)?

We have an ios app that uses native Facebook login just fine.
Then we also have a website (app is basically an optimized client for it) where people can login via Facebook too. When they open our website in mobile safari, they are directed to Facebook pages to authenticate there and it works, but.. it is still far from native and users have to retype credentials they often have in ios already.
So could it be possible to to somehow launch system fb authentication for just a web page (maybe using some clever URL schema?) and get granted token back to web?
Difficult way
As described here http://aaronparecki.com/articles/2012/07/29/1/oauth2-simplified#mobile-apps you could find URL scheme to trigger the native iOS app for app authorization:
fbauth://authorize?redirect_uri=[redirect_uri]&client_id=[client_id]&response_type=token
But if you call that link it's not possible to have a redirection. You could try to hack that redirection but maybe you could not find a way out.
A secure way to solve that problem is to use a SSO token to authenticate user on your App when he logs in, and next on Safari take a redirection, with a custom url to your APP, that do as bridge to FB App via Token stored in your APP. After FB authentication you can directly redirect user back to your landing page in Safari. As said by #Lego it's an alternative way to direct authenticate that could be made by going deep to custom URL used by FB.
No, it is not yet possible to directly authenticate the user via the native Facebook App, but it's possible to authenticate the user using a custom URL scheme which opens your native iOS app which then handles the authentication flow:
The user authenticates natively with your iOS App. You then store the user login (not password) in your app (i.e. using NSUserDefaults).
Then the user opens your web page in Mobile Safari. You redirect the user via a custom url scheme to your app (i.e. using myapp://authenticate). Apple documentation on implementing custom URL schemes: click
Now, if you have an active FB session in your iOS app, you can either directly redirect the user back to your landing page in Mobile Safari, passing the access token via url get parameter or you first re-authenticate the user, displaying a login view with the user name pre-filled, which you have stored in your iOS app before (step 1) and then redirect the user to your landing page, again all depending on session state and your security needs.
For opening face book app you can use Custom URL scheme. But i am not sure if u can authenticate user from it. In case if you could also then it will be confined up to the fb account which is already configured on that device app .so better try to use face book api or something
I don't get your question exactly but i think as per your question you want to create fb app Login in safari or in your custom web view.
is this perfect ?
as per my knowledge web view is different thing and native app is different thing.
if you are Login in web view then no need to check anything token or other thing because it will give you Logout thing there.
but if you are Login in your application then "developer.facebook.com" will definitely help you.
and yes, you will do most of the thing in your app as native facebook app do.
Hope it help....

Share using Facebook Application

Right now I'm using a Facebook SDK to share posts from my application. The problem is that this sdk pops up a webview inside my app and asks the user to log in. There has to be a better way.
Can I send the share information to the facebook app on the users device (If they have it installed)? Or at least leverage the facebook app to check credentials? If people have to sign in to share, they probably won't do it..
The latest Facebook SDK 3.5 includes a native share dialog. If you follow the authentication workflow according do the documentation and the phone is on iOS 6.0 you should not get a UIWebView during authentication, instead you will get a UIAlertView.
Facebook login process would use WebView only in a few cases. Some of them are:
1) You are asking it to do so explicitly, by using - (void)openWithBehavior:(FBSessionLoginBehavior)behavior completionHandler:(FBSessionStateHandler)handler; which, I think, is not your case.
2) If there is no Facebook app installed on the device, FB SDK falls back to using WebView login window.
3) Probably, this is your case. If you are requesting publish permissions on the first attempt to open FB session, FB SDK will also fall back to old login flow envolving WebView. In the new login flow, FB session is supposed to be open with read permissions first (in that case, FB will use fast app switching or native iOS FB login):
+ (BOOL)openActiveSessionWithReadPermissions:(NSArray*)readPermissions allowLoginUI:(BOOL)allowLoginUI completionHandler:(FBSessionStateHandler)handler;
Then, you should ask additional publish permissions from the user:
- (void)requestNewPublishPermissions:(NSArray*)writePermissions defaultAudience:(FBSessionDefaultAudience)defaultAudience completionHandler:(FBSessionRequestPermissionResultHandler)handler;
That way, user will not need to log in (if he is logged in FB app already), but there will be inconvenience of double switching from your app to FB (though it works rather fast lately).
I was looking for a cleaner way to get publish permissions with FB Single Sign On on the first call, but unfortunately didn't find anything working yet.

Login to Facebook comments using embedded UIWebView through Facebook SSO

Is there any method to login facebook comments embbedded in UIWebView using SSO?
In my case ,I am developing website and native ios app.
so I should embbed page like below link in my native app.
http://techcrunch.com/2012/09/19/facebook-contact-sync/
this page is using facebook comments.
If I ask users one more login, this problem can be solved.
But I want to login through facebook SSO.(Don't want to ask one more user's id and password)
Facebook-ios-sdk with embedded UIWebView
this link showing me how to login my comments box in UIWebView using ios SDK...
is Answer at this link possible?
Get Access token using iOS facebook SDK,
and passing this token to java script at page to authentication user at comments box.
If it is possible, How to pass access token that acquired from ios SDK to java script SDK ?
or Does there exist another method?
I think easiest way to implement this is make session cookies for webview using access token.
but people saying this is impossible.
Loading iPhone webviews as an Facebook SSO authenticated user?
is it still impossible at new version of SDK?
Thanks in advance!

Facebook iOS SDK: How to Persist Login to File or Database?

I'm fairly new to iOS development, and I'm starting work on an App that will include some simple Facebook integration. As a proof of concept, I made a bare-bones, view-based application that has a simple button to log a user in to Facebook, and then another button to post a status update.
This is all well and good, but in a real world scenario, a user shouldn't have to login to Facebook every time they want to use the Facebook-integrated features of my App. My question is this: how would I go about persisting a user's login to a file, or to a database for use in a later launch of my App?
Ideally this solution would use Facebook's iOS SDK, but I wouldn't be opposed to building my own authentication system using their Graph API. The advantage of using Facebook's official iOS SDK, though, is that it can use the login information already associated with the phone's Facebook application (if installed), or the login associated with facebook.com on mobile Safari.
I'm not providing my current source code, on the basis that this is a general enough question to not require the specifics of my Facebook SDK usage. However, if you think it would be helpful, I'd be more than happy to post my code.
Thanks!
you wouldn't do that. check out facebook SSO in their SDK ( see https://developers.facebook.com/docs/guides/mobile/ ). You request the facebook token everytime you use it or otherwise get an long-term (read: use access token offline_access) access token and persist this token to the NSUserDefaults for use in your app. ( see http://coffeeshopped.com/2011/01/saving-sessions-with-the-facebook-ios-sdk )

Resources