Facebook SDK 3.1 for iOS - runs on iOS6, but crashes on iOS 5.x
Did you set the frameworks to be optional? When you are adding AdSupport.framework, Social.framework, and Accounts.framework, there is drop down menu to the right that you can select between "Required" and "Optional". See a picture example here:
Link
Another thing to check is in your Project's "Build Settings" that 'Base SDK' is 6.0 and 'iOS Deployment Target' is iOS 4.3.
I'm able to build FB SDK 3.1 on my iOS 5.1 with these settings.
New Facebook SDK for iOS 6 has a crash issue in iOS 5
Set the frameworks that are giving you problems to "Optional" instead of "Required" by going to the project file Summary and scrolling down to Linked Frameworks and Libraries.
Facebook iOS SDK: App crashes right after starting with Symbol not found: _ACFacebookAppIdKey. only in iOS 5
This is a known bug which has been fixed (but the fix hasn't reached any stable version of Xamarin.iOS yet - the bug report says it'll be included in the 6.2.2 release, but that didn't happen).
Currently the only known workaround is to use an older version of the Facebook SDK.
Facebook iOS SDK 3.1 crashes on subsequent call to FBSession openWithBehavior
When I ran in the 5.x simulator, I saw an extra, very helpful, error message from openWithBehavior, then looked it up in the source which makes things much more clear:
if (!(self.state == FBSessionStateCreated ||
self.state == FBSessionStateCreatedTokenLoaded)) {
// login may only be called once, and only from one of the two initial states
[[NSException exceptionWithName:FBInvalidOperationException
reason:@"FBSession: an attempt was made to open an already opened or closed session"
userInfo:nil]
raise];
}
I've changed my code to always create a fresh session before calling openWithBehavior and it seems happy.
UPDATE:
Here's the updated code that checks for an active session, then closes it, before always instantiating a fresh session...
- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI {
if ([FBSession activeSession])
[[FBSession activeSession] closeAndClearTokenInformation];
#ifdef FREE_APP
NSString* suffix = @"free";
#else
NSString* suffix = @"paid";
#endif
NSArray *permissions = [[NSArray alloc] initWithObjects:@"email", nil];
FBSession *session = [[FBSession alloc] initWithAppID:mFacebookID
permissions:permissions
urlSchemeSuffix:suffix
tokenCacheStrategy:nil];
[FBSession setActiveSession:session];
If (allowLoginUI == YES) {
NSLog(@"Calling openWithBehavior");
[[FBSession activeSession] openWithBehavior:FBSessionLoginBehaviorUseSystemAccountIfPresent
completionHandler:^(FBSession *session, FBSessionState state, NSError *error)
{
[self sessionStateChanged:session state:state error:error];
}
];
} else if(session.state == FBSessionStateCreatedTokenLoaded) {
NSLog(@"Calling openWith completion handler");
[session openWithCompletionHandler:^(FBSession *_session, FBSessionState status, NSError *error)
{ [self sessionStateChanged:session state:status error:error];}
];
}
[session release];
return true;
}
Why does Facebook SDK for iOS 6 fail on some users but succeed on others?
I experienced the same issue. The core seems to be the fact that when you have FB credentials in the settings app, Facebook uses one route to authenticate. When you remove it, FB checks against the stored settings and fails and returns a close-state. It was expecting to be able to use the session but that was destroyed.
Keep in mind in a real-world setting, your user is not going to be toggling between the setup that way. It is very disconcerting when you are testing various scenarios on your device, but a real-world user is not going to attempt different user logins or different user-credential on/off scenarios.
Related Topics
How to Reference Instance Function When Calling Sequencetype.Foreach
Error When Trying to Call Setdata(From: ) in the Cloud Firestore iOS API. How to Fix It
Firebase .Indexon Dynamic Keys
Count Unseen Messages with Firebase in Swift
How to Store Push Notification Alert Message in Userdefault
Swift - Using Replacerange() to Change Certain Occurrences in a String
Different Font Size for Different Devices in Xcode 6
Selector to Get Indexpath Uicollectionview Swift 3.0
Retain Cycle (Strong Reference) Fix for Custom Uitextfield
Using Existing System Sounds in iOS App [Swift|
Add Uipickerview in Uiactionsheet from iOS 8 Not Working
iOS - Delayed "Touch Down" Event for Uibutton in Uitableviewcell