Unable login with FBLogin view on iPhone 5 - ios

I've created Facebook app using Facebook login flow from the developer page step by step. Login works great. My problem is that this is not working on iPhone 5 or 5s.
I have tried to check on 6 different iPhones 5 and it works only on one of them. Once I've clicked on "login" I get alert with the message the app would like to access to you basic info I get the user cancel login error once I click on "ok" or "don't allow" in the alert. and nothing happens. any idea what could be the problem? thank you

Instead of using FBLoginView, try using FBSession like this:
// no action can be done on facebook if there is no session on open state
if (!FBSession.activeSession.isOpen) {
FBSession *session = [[FBSession alloc] initWithPermissions:#[#"email", #"user_birthday"]];
[FBSession setActiveSession:session];
// Here this behavior garantees that the iOS Login Dialog is not shown, because it was causing some login issues
// The fallback flow will be: 1- Facebook App Native Login Dialog; 2- Facebook App Web Login Dialog; 3- Mobile Safari Login Dialog
[[FBSession activeSession] openWithBehavior:FBSessionLoginBehaviorWithNoFallbackToWebView
completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
if(error) { // your code here }
else { // your code here }
}}];

Related

Stop Do you want to open facebook prompt when i called "logInWithReadPermissions" method in iOS

I am using iOS SDK Facebook to login into my app. I have a Facebook login button (my own button, not the one provided) and it shows perfectly either the Facebook App (if is installed) or the Safari, and after that the facebook login page.
ISSUE: When i installed facebook and i click login with facebook button its asking "Do you want to open facebook" with open and cancel button. when i click open button the handler calling automatically.
[login logInWithReadPermissions:#[#"public_profile",#"email"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
//Checking for success login
if (result) {
//user login successfully, get user information
} else {
//user login failed
NSLog(#"facebook error %#", error);
}
}];
When i tried to get user inoformation in success method iam getting error.How can i stop asking prompt Do you want to open facebook when i click on facebook button first time. And why success block is calling when i press open button.
Change the login behavior to:
login.loginBehavior=FBSDKLoginBehaviorWeb;
As default login behavior is via the application or native safari browser.
Changing it will prevent prompt from opening.

Facebook SDK iOS - "Update your browser"

I am trying to enable "Login with Facebook" in one of our apps, like this:
[FBAppCall handleDidBecomeActive];
if ((FBSession.activeSession.state == FBSessionStateOpen) || (FBSession.activeSession.state == FBSessionStateOpenTokenExtended))
{
[FBSession.activeSession closeAndClearTokenInformation];
return;
}
[FBSession openActiveSessionWithReadPermissions:#[#"email"] allowLoginUI:YES completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
}];
When I am logged in to Facebook on the iOS device (through Settings), I see a popup asking me if I want to allow access - I can accept it and everything is fine.
However, when I am not logged in, I will just see a browser "popup" telling me that my browser is not supported. I am using a custom button, from where I then call the code above. This code is taken directly from the tutorial. How can I get this to work? Any help would be highly appreciated.
Found the problem: The value in "URL Schemes" had a typo...

ios facebook sdk error systemlogincancelled

I am getting a facebook sdk error on ios when I try to login -- note that I just upgraded the version of my facebook sdk to version 3.21.1. The interesting thing is that it works fine on the simulator. When I log into facebook on my iphone under settings => facebook the facebook login on my app fails, but when I disconnect the native facebook login it works fine again.
Here is my code:
NSArray * basicPermissions = #[#"public_profile", #"user_friends", #"email"];
[FBSession openActiveSessionWithReadPermissions:basicPermissions allowLoginUI:YES completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
[DCTLogger debug:#"facebookLoginQ:Callback: %#/%p sess=%# ", [DCTBase stringForFBSessionState:status], error, session];
if (error) {
dispatch_async(q, ^{
handlerCopy(nil, error);
});
return;
}
if (status == FBSessionStateOpen) {
[FBSession setActiveSession:session];
[self facebookSessionCreatedQ:q Callback:handlerCopy];
}
}];
The error I get is com.facebook.sdk:ErrorLoginFailedReason=com.facebook.sdk:SystemLoginCancelled with facebook sdk error code 2.
Another interesting point is that if I remove public_profile from basicPermissions the login works fine, and as per another post I saw about this, if I use the deprecated method of openActiveSessionWithPermissions as opposed to openActiveSessionWithReadPermissions it works fine as well.
Just want to point out again that it only seems to fail when there is a natively logged in facebook account on the device. I have a feeling that perhaps the new sdk automatically includes public_profile so if I request it again in basicPermissions it causes an issue.

iOS Facebook SDK Login View sometimes shows Desktop Web rather than Mobile Web

I'm using the latest FB SDK via Pods - version 3.18.2, with Xcode 5 in and iPhone only app. I use the FBLoginView in the Storyboard, so tapping it pops open the Facebook login for the app, and login actions call the delegate of the parent View controller of that FBLoginView button.
It all works fine -- but, sometimes the Desktop version of the login shows up rather than the Mobile version. It's intermittent -- I have tester where it never shows, one who gets it sometimes, and one who gets it often.
Any idea how I can prevent the SDK from showing the Desktop login?
If the user doesn't have the Facebook native app installed the facebook website will open.
Otherwise it will open the Facebook native app.
There is a function called openWithBehavior in the Facebook SDK that works on sessions. Use that like I have shown below:
FBSession *session = [[FBSession alloc] initWithPermissions:#[#"public_profile", #"email",#"user_location",#"user_birthday",#"user_likes"]];
[FBSession setActiveSession:session];
[session openWithBehavior:FBSessionLoginBehaviorForcingWebView
completionHandler:^(FBSession *session,
FBSessionState status,
NSError *error) {
if (FBSession.activeSession.isOpen) {
//Do Something
}
}
]

Facebook Login Using FBSessionLoginBehaviorForcingWebView

I am using the following code to present the user with the Facebook Embedded WebView Dialog in an iOS 7 app
FBSession *session = [[FBSession alloc] initWithPermissions:#[#"basic_info", #"email"]];
[FBSession setActiveSession:session];
[session openWithBehavior:FBSessionLoginBehaviorForcingWebView completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
[self sessionStateChanged:session state:status error:error];
}];
On my development iPad, I see the Facebook dialog and login view just fine. On iPhone, the dialog fills the screen just fine, but the spinning progress indicator just sits there forever. Our QA team is seeing the never ending spinning progress indicator on both devices.
Has anyone else seen this behavior? I am about to give up and just implement the Mobile Safari Login Dialog.
I use
FBSessionLoginBehaviorWithFallbackToWebView
and it works for me.
EDIT: You may also want to check to make sure you have the Advanced setting "Embedded Browser OAuth Login" turned on for you Facebook app.

Resources