问题
Facebook SDK documents indicates that this SDK will work on iOS 4.0 and later. Then I tested their Scrumptions sample on a iPhone 3GS iOS 4.0 device. But it seems this application doesn't work. It keeps showing me the login screen although I logged in.
Then I debugged and noticed FBSessionState
always returnsFBSessionStateClosedLoginFailed
.
It never returns FBSessionStateOpen
.
What could be the reason? However when I run this in iOS 5.1 emulator it works fine. Is it because SDK doesn't support iOS 4.0 or some other issue?
回答1:
Did you declare both
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation;
and
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url;
?
The first one is iOS 4.2 and later so if your device is running with a version prior 4.2,the second method will be used instead.
回答2:
Just like saulobrito stated. I got this problem myself and solved it by implementing this method in the app delegate
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
return [FBSession.activeSession handleOpenURL:url]; ;
}
You don't have to implement the handleOpenURL
来源:https://stackoverflow.com/questions/11924651/facebook-sdk-for-ios-on-ios-4-0-device