Facebook iOS SDK集成在Appdelegate.m中显示错误

时间:2014-01-27 10:57:50

标签: ios objective-c facebook facebook-sdk-3.1

在https://developer.facebook.com中,他们已经使用API​​调用Sample进行登录,他们要求在我的app delegate.m文件中键入以下代码

// Whenever a person opens the app, check for a cached session
if (FBSession.activeSession.state == FBSessionStateCreatedTokenLoaded) {

  // If there's one, just open the session silently, without showing the user the login UI
  [FBSession openActiveSessionWithReadPermissions:@[@"basic_info"]
                                     allowLoginUI:NO
                                completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
                                  // Handler for session state changes
                                  // This method will be called EACH time the session state changes,
                                  // also for intermediate states and NOT just when the session open
                                  [self sessionStateChanged:session state:state error:error];
                                }];

它向我显示错误,如'不可见@interface'AppDelegate'声明'sessionStateChanged:state:error:' 提前谢谢......

1 个答案:

答案 0 :(得分:4)

根据上面的链接,您必须在您的app委托中添加此方法..但您可以根据您的状态视图自定义此方法(state == FBSessionStateOpen ... etc)

// This method will handle ALL the session state changes in the app
- (void)sessionStateChanged:(FBSession *)session state:(FBSessionState) state error:(NSError *)error
{
  // If the session was opened successfully
  // customize your code...
}