One time login through Facebook in iOS app - ios

I have a app which has a login option which is only through the Facebook account. But when I run the app in simulator it always ask for login again and again when I am going to run my app. I want to show the main view if user is already logged in through the Facebook and when user delete the app and install again then user has to log in again to the app.

You should be saving a single sign on token? The simulator will fallback to 0Auth and may not be realistic, but it should remember it none the less.
Which version of the FaceBook SDK are you using?

Related

What is the expected behaviour of Facebook login?

I want to know what the expected behaviour of Facebook login integrated in an iPhone app is, when a user is already logged into Facebook on the device through Facebook app, and the app is granted the required permissions in the previous login. I want to know if the app exits and starts again, should it still switch to Facebook app/website to check the permissions or should it silently log the user in without getting out of the app? Currently, my app switches to Facebook, detects that the user has already granted access, asks for an Ok or Cancel and comes back to the app. I wan to know if this behaviour is expected, because it seems it's doing nothing but unnecessary switching. I have asked this question in another form and I have included my code. Here's the link: http://bit.ly/1E1u2VI
Thank you!
It silently log the user in without getting out of the app. For that you can check the current user's permissions.
This might help you:
Controlling Login dialogs
The Facebook SDK automatically selects the optimal login dialog flow based on the account settings and capabilities of a person's device. This is the default sequence that the Facebook SDK implements:
Facebook App Native Login Dialog
Facebook App Web Login Dialog
Mobile Safari Login Dialog
If the Facebook account is not set up, the Facebook SDK checks to see if the Facebook app is installed on the device. If the Facebook app is installed, the Facebook app native login dialog is presented if it's supported. If the Facebook app native login dialog can't be displayed because there's an old version of the app, the Facebook app web login dialog is presented. If the Facebook app isn't installed, mobile Safari is launched to display the Mobile Safari login dialog.
Here are the screenshots of code
I have checked the login process using safari browser it's work for me. [FBSDKAccessToken currentAccessToken] is working fine. I am attaching some screenshots might help you.

Facebook unable to retrieve iPhone Store ID?

I'm trying to set up an iOS 6.0 and up app on Facebook developers, everything's hooked up and working fine using the latest SDK. The problem is that, though authentication works fine, later in the app it's requesting post permissions and when a Facebook account is not a member of the Facebook app in the Dev center, these permissions aren't requested, the screen just pops to Facebook and back to the app again without doing anything. When I try to use the app with my account that is an admin on Facebook Dev, then it works.
The posting action in question is a Facebook Graph post and it works fine for the admin account.
In previous apps I haven't requested publish permissions through the Facebook developer portal in the app settings (you know, the app review bit by Facebook), so that can't be it either. Those apps work with accounts that are not a member.
I know the code is fine, the code is re-used from previous apps.
I think it's because I am unable to enter the proper Facebook app ID in the Settings. Could that be the cause? Though the app ID is in iTunes Connect, Facebook can't find it yet because the app in review at Apple.
Any thoughts on this nightmarish user rights issue?
Since API v2 was introduced, with every new app you need to go through review for any permission apart from the three “basic” ones (those are public_profile, email and user_friends) – see https://developers.facebook.com/docs/facebook-login/permissions/v2.1
Otherwise you will only be able to ask users that have a role in the app (admin/developer/tester) for permissions – that is helpful either during testing, or for an app that is for a limited user base only; f.e. if you want your app to publish updates from your website to your Facebook page, which requires manage_pages – in such a case you should not submit for review, but just use that permission with your admin/developer/tester account associated with the app. That is further explained here – https://developers.facebook.com/docs/apps/faq#apps-all-users-are-developers

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.

How to avoid "App is allready authorized" with Facebook SDK 3.1

Every time i want to login through the Facebook idk, safari will be opened and tells me that my app is allready authorized. But i dont want to show this screen everytime a user logs in with Facebook. I followed the instructions over here to implement facebook login functionality. If the auth button is clicked i simple call the openSessionWithAllowLoginMethod which then handles the rest for me. But i dont how to apply the functionality, that it wont show the authorized screen everytime, to this code ? I would really appreciate some tips or hints.
Fill out every field related to your app in the Native iOS App section of the Basic Settings in the App Dashboard. If these fields are not configured, we can't drive traffic to your app or the iOS App Store. In addition, we use the iOS Bundle ID to streamline authentication for users who already authenticated your app. Pro-tip 3: Complete all iOS App Settings

facebook dialog ios for login

I have followed the example of Facebook SDK for iOS (Hackbook) and it works well however whenever the person is logging in the app takes take the person to Safari or the Facebook app (if you have it installed on the device). Is there a way I can call the permission without leaving the app.
Thanks
there once was. But facebooks says that you should use SSO (single sign on) with the official facebook app. So even if you'd modify the files of the facebook-ios-sdk, it would probably not work.

Resources