Facebook SDK iOS error 2 - ios

I'm trying to log into facebook with their API using
[FBSession openActiveSessionWithReadPermissions:permissions
allowLoginUI:YES
completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
[self sessionStateChanged:session state:state error:error];
}]
The problem I'm having is in iOS 6.x when the device has a facebook account linked in the settings app it fails to log in. The error it gives is the seemingly one-size-fits-all error 2. This is the only case where it fails and I can't understand why. What is a solution to let me log in while an account is linked?

check that your permissions array does not contain the offline_access permission. this permission is now deprecated and has been known to cause login to fail. i previously searched stack overflow and found this answer. you'll also need to go into Settings -> Facebook and switch the permission on the Allowed Apps to On.

I was getting this error due to the app being sandboxed. Check facebook developer and add your team.

Go to settings. Scroll all the way down until you see Facebook on left hand side
tab, on it, allow these apps to use your account (right hand side).
Look for the app that gives you the sdk error 2.

Related

Multiple facebook app id for a single iOS application

Currently I am using FBSDKLoginManager with a Facebook app id to sign in via Facebook into my application. I have the required things in .plist file. Everything works fine.
But now I have to login in another section of my application with a different Facebook app id. How could I use different Facebook app id in a single application in various area.
Someone already asked this question previously. From the answer I found
FBSession *session = [[FBSession alloc] initWithAppID:#"AN_APP_ID"
permissions:nil
defaultAudience:FBSessionDefaultAudienceNone
urlSchemeSuffix:nil
tokenCacheStrategy:nil];
[session openWithCompletionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
// do stuff here
}];
But the answer does not work for me as FBSessionis not available. Any idea? Suggestion?
Refer to this tutorial that specifically addresses your problem in particular, and how to manage different environments in general: https://medium.com/slalom-engineering/ios-managing-multiple-environments-with-a-single-target-94cf823a6447
To go directly into what you want, search for "FacebookAppID" on that link.

IOS Facebook SDK 3.17: Doesn't give me publish_stream permissions (while older versions as well as android both work -- so it is sdk specific)

The IOS Facebook SDK (3.17) doesn't give me publish_stream permissions (while older iOS versions and also android work fine -- so it is sdk specific)
What I do is straight forward
1 I get readPermissions
[FBSession openActiveSessionWithReadPermissions:permissions allowLoginUI:YES completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
...
2 Later I call requestPublishPermissions
[[FBSession activeSession] requestNewPublishPermissions:#[#"publish_stream"] defaultAudience:FBSessionDefaultAudienceFriends completionHandler:nil];
3 I do a NSLog => no publish_X permissions (I can get publish_actions but thats it)
NSLog(#"%#", session);
FB support:
Hi
Publish_stream and Publish_actions have been streamlined into just "publish_actions". You can read about it here at https://developers.facebook.com/docs/ios/graph and at https://developers.facebook.com/docs/facebook-login/permissions/v2.1
Note that you will have to get your app approved by submitting it for review before you can use these permissions with users other than your test users and admins of your app.
Apps that have been granted publish_streams permissions will continue to work the same way as before.

AppCenter Rejection - missing (NOT) SSO

I have a problem with App Center Review. I have an iOS application which has the Single Sign-On implemented (I just tested it on both types of devices). Still, when I submit my app's page for App Center Review I always get the same message (see screenshot below).
I don't know what to do anymore. It has been like this for at least few months now. I checked everything in my application, even was able to post an update in the meantime, and the page still get's rejected. The message is always the same so I don't get any more info about the error (which in my opinion does not exists).
What should I do with this issue? Who can I contact directly about it (via email preferably)?
Edit #1: In my opinion I am using the native login screen. I am 100% sure that I use official FB API (downloaded from FB page). When I connect with FB in my application the screen that pops up is a screen from FB application (see below).
Edit #2: Okay, so I've implemented new way of logging in with FB but still native login view is not presented. Instead, the login screen of FB application opens up, which is exactly the same behaviour as before... I have the FacebookDisplayName set in the .plist file.
[FBSettings setDefaultAppID:#"some_facebook_app_id"];
[FBSettings setDefaultUrlSchemeSuffix:#"some_suffix"];
[FBSession openActiveSessionWithReadPermissions:#[#"basic_info"] allowLoginUI:TRUE completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
// handler logic goes here
}];
Edit #3: yeap, the new API was the solution. Thanks!

new facebook account in iOS 6 settings

I am using following code to access the facebook
[FBSession openActiveSessionWithAllowLoginUI:TRUE];
NSArray *permissions = [[NSArray alloc] initWithObjects:
#"email",
nil];
[FBSession openActiveSessionWithReadPermissions:permissions allowLoginUI:true
completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
if (error) {
NSLog(#"Failure");
}
else
{
}];
It is working fine when user has enabled the facebook account in iOS setting and also when there is no account enabled in iOS settings then it goes to safari for facebook authentication. But suppose user has first enabled the account with abcd#gmail.com and then after some time he has added new account i.e. efgh#gmail.com. So how the app come to know that user has changed his/her account in iOS settings. How to check it by using facebook SDK. Anyone has idea?
Thanks to all.
The information (access token, etc) stored inside a FBSession is entirely independent of any other account authority (this includes iOS6, Safari, or the Facebook app). Those other authorities are only used to connect your app, once it's connected, your app operates independently. This means that even if the user logs out, and logs in again with a different id, it doesn't affect your app at all. The user of your app needs to proactively log out inside your app, and initiate another login in order to change accounts.
This is why it's vitally important that the user has a way of identifying themselves inside of your app (either through a profile picture, and/or their name displayed somewhere), so they know which account they're using.

How to get native Facebook login on iOS using SDK 3.1?

I downloaded the new Facebook iOS SDK 3.1, which promises to have a native login prompt. I ran their sample login app on my iOS 6 device. When I attempted to connect with Facebook, I did not get a native login. Instead, the Facebook app launched - same as the old SDK. Their Facebook login button basically does this:
[appDelegate.session
openWithCompletionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
[self updateView];
}
];
I thought maybe the sample code isn't calling the right function. So I tried FBSession's other login function.
[appDelegate.session
openWithBehavior:FBSessionLoginBehaviorWithNoFallbackToWebView
completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
[self updateView];
}
];
I tried all possible behaviours and none of them popped up the native login prompt.
Did you log into Facebook from the iOS settings first?
Once you do that, their example project Scrumptious will use the native login prompt when you try to connect.
Read this: https://developers.facebook.com/docs/howtos/ios-6/#nativeauthdialog
Basically you must request basic permissions and read permissions first and then request publish permissions separately.
This is by design, and described in the second section of https://developers.facebook.com/docs/getting-started/facebook-sdk-for-ios/3.1/upgrading-from-3.0/
Basically, you are not able to ask for both read and publish permissions with the iOS6 dialog. Therefore you are more-or-less required to ask for them in a staggered way (e.g. read on first login, and then publish when your app actually needs to publish).
If you insist on using the deprecated method to try and get read & publish at the same time, the SDK has no choice but to return to the web or app-switched technique.

Resources