1

在 htttps://developer.facebook.com 中,他们使用 API 调用示例登录,他们要求在我的应用程序 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];
                                }];

它向我显示错误,例如 ---- No visible @interface for 'AppDelegate' 声明了 'sessionStateChanged:state:error:' 提前谢谢...

4

1 回答 1

4

根据上面的链接,您必须在您的应用程序委托中添加此方法。但是您可以根据您的状态视图自定义此方法(状态 == FBSessionStateOpen ...等)

// 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...
}
于 2014-01-27T11:09:24.120 回答