Facebook SDK iOS - "Update your browser" - ios

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...

Related

Facebook iOS SDK 3.x - publish permisisons

Facebook integration in my app works well. I ask for *read_stream* permission at login, then for *publish_actions* when I want to publish anything for the first time (as recommended).
The issue is, that when I ask for *publish_actions* permission, app switches to Facebook app and back. I wouldn't like user to see Facebook app, and I know many apps that post to the wall silently.
How can I do this?
You should ask for publish permission on login, not when publish something for the first time.
Once the user is logged in with all needed permission, he won't see the fb app screen again (unless the session expired or is closed).
[FBSession openActiveSessionWithPublishPermissions:#[#"publish_actions"]
defaultAudience:FBSessionDefaultAudienceFriends
allowLoginUI:YES
completionHandler:aCompletionHandler];
if You did ask about public_action in the first time user login you not need it again. U need check active permission. If public_action found you not need call to get it a gain
// Ask for publish_actions permissions in context
if ([FBSession.activeSession.permissions indexOfObject:#"publish_actions"] == NSNotFound) {
// Permission hasn't been granted, so ask for publish_actions
[FBSession openActiveSessionWithPublishPermissions:#[#"publish_actions"]
defaultAudience:FBSessionDefaultAudienceFriends
allowLoginUI:YES
completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
if (FBSession.activeSession.isOpen && !error) {
// Publish the story if permission was granted
// write your code public here
}
}];
}
else {
// If permissions present, publish the story
// write your code public here
}

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.

Unable login with FBLogin view on iPhone 5

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 }
}}];

read and publish permission in facebook sdk 3.0 iOS

In the last SDK, read and publish permissions are separated. So, in my code, whenever the users logs in I am using this code:
[FBSession openActiveSessionWithReadPermissions:nil
allowLoginUI:YES
completionHandler:
^(FBSession *session,
FBSessionState state, NSError *error) {
[self sessionStateChanged:session state:state error:error];
}];
I have seen in the facebook developer that when I want to publish, I should ask for publish permissions like this:
// can include any of the "publish" or "manage" permissions
NSArray *permissions =
[NSArray arrayWithObjects:#"publish_actions", nil];
[[FBSession activeSession] reauthorizeWithPublishPermissions:permissions
defaultAudience:FBSessionDefaultAudienceFriends
completionHandler:^(FBSession *session, NSError *error) {
/* handle success + failure in block */
}];
Since this is my first app that I am using facebook integration, I want to ask a couple of things:
1) Can these sessions be open at the same time? I will ask for the publish permissions only when the user wants to publish, but should I do something else with the other session? Like close it first, and reopen it later or I should not worry about?
2) If I have a postToFriends button for example, my pseudocode for making it work would be like this, right?
- (IBAction)postToFriendaction:(id)sender {
if (!FBSession.activeSession.isOpen) {
/* code from the above for enabling publish permissions*/
}
or I should change !FBSession.activeSession.isOpen to something else, because no the user is logged in with read permission only, he never enters the if clause. Can you help me?
The two sessions you refer to are actually the same session (it's the "active" session that's statically available after a call to openActiveSession... is called). So you don't need to do anything with the other session.
You should have a look at either the Scrumptious or Hello Facebook sample apps that ship with the SDK. They both give examples on how to post (while asking for publish permissions).

iOS – Facebook SDK 3.1.1 access alert doesn't show after app is removed from facebook.com

If remove my app from Facebook App Center and then I try to authorize my app with
[FBSession openActiveSessionWithReadPermissions:permissions
allowLoginUI:allowLoginUI
completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
[self sessionStateChanged:session state:state error:error];
}];
The alert ("Don't allow", "OK") that should be displayed requesting for access is not shown, instead when the completion handler is called FBSessionState will be FBSessionStateOpen which is wrong.
The second time I try to authorize it will always show the access alert correctly.
Am I the only one experiencing this? Is there a solution for this issue?
We now have better error handling in our new SDK 3.2.
Please check out our new SDK release 3.2 here: https://developers.facebook.com/blog/post/2013/02/25/facebook-sdk-3-2-for-ios/

Resources