Facebook SDK FBSession infinite loop and crash - iphone

I originally used FBLoginView to start the login process in the latest Facebook SDK (3.5). However, that would crash the app because of a loop of some sort. I then read that I should try logging in using the code below as a test:
[FBSession openActiveSessionWithReadPermissions:[NSArray arrayWithObjects:#"read_stream", nil] allowLoginUI:YES
completionHandler:^(FBSession *session,
FBSessionState status,
NSError *error) {
// session might now be open.
NSLog(#"Error - %#", error);
}];
I got exactly the same issue. A huge number of processes (with the same name) get called and the app crashes. Does anyone know why this would happen when using the Facebook SDK? Here is an image of the thread that crashes:
As you can see there's something not right here. Anyone got any ideas?
Regards,
Mike

This was a bug and is now fixed.
Edited --
This has been fixed on both client and server as of the Facebook SDK 3.5.1 for iOS. Here is the link:
https://developers.facebook.com/resources/facebook-ios-sdk-3.5.1.pkg
--
Thanks for notifying us of this problem!

I had the same issue, and tried setting sandboxing (in fb app dashboard) to false, and then it worked...

I'm having what seems to be the exact same problem, and nearly the same stacktrace,but I already have sandboxing disable, in fact, my app has been in production for 9 months, but we were using still sdk 2.0 and just gotten around to upgrade it.
I have narrowed It down a lot. Here I give a good explanation about my problem, and a temporary solution that fixes my problem, but It's viable for production..
Facebook SDK FBLoginView getting EXC_BAD_ACCESS

Related

Facebook posting error in ios

Here i am trying to add a post to facebook using following code.
FBAppCall *appCall = [FBDialogs presentShareDialogWithLink:urlToShare
name:#"Title"
caption:nil
description:#"description"
picture:nil
clientState:nil
handler:^(FBAppCall *call, NSDictionary *results, NSError *error) {
if (error) {
NSLog(#"Error: %#", error.description);
} else {
NSLog(#"Success!");
}
}];
But this isn't working. It give following error.
Error Domain=com.facebook.Facebook.platform Code=102 "The operation couldn’t be completed. (com.facebook.Facebook.platform error 102.)" UserInfo=0x1cde3340 {error_code=102, action_id=E780C3AA-1387-4B9C-9A3A-9A16FB54BC59, error_message=An error occurred during publishing., app_id=558567750859724}
Here i am working on cocos2d, is this can be the reason.
Go to your app's settings under the Facebook developer portal.
Go to open graph > types
Choose the action type using and turn on "User Generated Images" for that action type. Save these settings and try again. It will work.
I encountered this error as well, make sure you disable the sandbox mode in Facebook admin panel before distributing to any other user :P
I recently encountered this error when the link I tried to post did not load correctly (was loading a 404 page). Not sure why, but maybe Facebook requires the link work.. Either way they need to make their error messaging more specific.

Facebook iOS SDK 3.1 openActiveSession.. always returns 0

I am working on an application that needs to be able to upload an image for the app for iOS versions 5.0+. For iOS 6, I have easily implemented the social feed that works perfectly.
For iOS 5, I am using the Facebook iOS SDK version 3.1. I use the methods that were in the tutorials, and so when I got to publish the image on iOS <6.0, I call the following method:
- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI
{
return [FBSession openActiveSessionWithPublishPermissions:[NSArray arrayWithObjects:#"publish_actions", nil] defaultAudience:FBSessionDefaultAudienceFriends allowLoginUI:allowLoginUI completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
[self sessionStateChanged:session
state:status
error:error];
}];
}
With [self openSessionWithAllowLoginUI:YES]; I always get back NO (0) and sessionStateChanged:state:error is never called due to it returning 0.
I have the app set up correctly, the two different parts set up in the plist, etc. etc., but for some reason this code on my iOS 5.0 device does not want to return correctly. (Just like in openSessionWithAllowLoginUI almost always returns NO)
Does anyone have any solutions on why it would always be returning no? I have the official FB app installed on the device, I am logged into my account...I am not getting any errors or anything...
Thanks in advance!

Facebook iOS SDK Logout

I'm using the official and updated Facebook iOS SDK.
We're developing an application on an iPad that is used inside a physical store using an in-house distribution profile. Where customers can login to their Facebook account on an iPad that's publicly available to improve their shopping experience.
The problem I came across is that when a user logs into their Facebook account, the next user (customer) will still be logged in with the previous users' credentials (You have already authorized xxx, Press "Okay" to continue). Ofcourse this is not okay.
Is there a way to actually logout (sign off, clear credentials, or what ever) the previous (or current) user so the next user can fill in its own username and password.
Unfortunately [[FBSession activeSession] closeAndClearTokenInformation] doesn't quite do the trick.
This is a part of the code so far:
// ....
[[FBSession activeSession] closeAndClearTokenInformation];
[FBSession.activeSession openWithCompletionHandler:^(FBSession *session,
FBSessionState state,
NSError *error) {
// More code ...
}];
// ...
PS. The cookie 'workaround' doesn't work for me (obviously)
From your context, I'm assuming your device(s) does not have the Facebook app installed nor do you expect to use iOS 6 system authentication which would leave the default login behavior to use Safari. If you were to clear the Safari cookies, that should work but for a smoother experience in your scenario you should use the FBSession openWithBehavior:completionHandler: method and specify a behavior of FBSessionLoginBehaviorForcingWebview so that it uses the inline webview dialog for authentication.
See the SwitchUserSample in the Facebook iOS SDK for an example since that sample demonstrates an app that can toggle between multiple accounts.
Try with this code. I think it will help you.
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
[login logOut];
If you are using facebook sdk 4.1.0 just call bellow method
if ([FBSDKAccessToken currentAccessToken]) {
[FBSDKAccessToken setCurrentAccessToken:nil];
[FBSDKProfile setCurrentProfile:nil];
}

Facebook login on iPhone app

I am trying to allow users to login to my app, through Facebook. I am following this guide https://developers.facebook.com/docs/howtos/login-with-facebook-using-ios-sdk/
I have followed all of the steps including the step named "Getting started with the Facebook sdk for iOS".
When I copy and paste the following method, I get an error here:
return [FBSession openActiveSessionWithPermissions:permissions
Here is the method I copied and pasted.
- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI {
NSArray *permissions = [[NSArray alloc] initWithObjects:
#"user_likes",
#"read_stream",
nil];
return [FBSession openActiveSessionWithPermissions:permissions
allowLoginUI:allowLoginUI
completionHandler:^(FBSession *session,
FBSessionState state,
NSError *error) {
[self sessionStateChanged:session
state:state
error:error];
}];
}
The error says this: "No known class method for selector 'openActiveSessionWithPermissions:allowLoginUI:completionHandler:'"
Can someone help me figure out what I am doing wrong?
Let me know if you'd like to see some more of my code to figure the problem out.
update you facebook sdk to the latest one, and follow Scrumptious example.
I really doubt this is gonna solve your problem, but it's worth a shot. NSError usually takes an ampersand ("&") before getting passed as an argument. So write it as error:&error instead.
Complementing mLamaa answer, take a look on Facebook Upgrade Guide and follow these 2 steps:
1- Update facebook SDK
2- Replace the openActiveSessionWithPermissions function to openActiveSessionWithReadPermissions
Reference:
https://developers.facebook.com/docs/ios/upgrading/
Upgrading from 3.0 to 3.1
"Therefore, if your app previously used v3.0 of the SDK, you will need to remove usage of openActiveSessionWithPermissions:allowLoginUI:completionHandler: and replace it with openActiveSessionWithReadPermissions:allowLoginUI:completionHandler: (or even more simply, openActiveSessionWithAllowLoginUI)."

FBConnect iPhone: Unknown Error Occurred

I'm uploading photos to Facebook from my iPhone application. I've got it working, except that sometimes, it returns "Unknown Error Occurred". I'm not sure what the problem is. This happens about 75% of the time.
Has anyone else encountered this?
Still not sure what was happening, but I solved the problem. Here's what I did:
- (void)request:(FBRequest*)request didFailWithError:(NSError*)error {
if ([error code] == 1 && [[request method] isEqualToString:#"photos.upload"]) {
FBRequest *tryAgain = [FBRequest requestWithDelegate:self];
[tryAgain call:[request method] params:[request params] dataParam:(NSData *)[request dataParam]];
}
}
Essentially, I just made it try again. Resending the same request didn't work (failed with an invalid signature), so I created a new request with the properties of the old one.
The nice thing about this is that it is sort of recursive: if the new request fails too, it will just keep trying. I hope I don't encounter any negative side-effects of that, though.
Try it on the simulator and use an http debugger like Charles to see what is happening during the transfer and what the response is from Facebook.