我正在尝试使Facebook 3.1 SDK与iOS 4.3+一起使用,并在应用程序从身份验证返回后显示对话框,但是我在身份验证和显示用于旧版本Facebook SDK的对话框时遇到了麻烦。
我已经阅读了Facebook文档,但其中一些内容不是很清楚,有些东西已贬值,而另一些则不起作用。任何在正确方向上的帮助将不胜感激。
谢谢

最佳答案

如果您使用最新的SDK,请尝试以下代码。

[FBSession openActiveSessionWithReadPermissions:[NSArray arrayWithObjects:@"read_stream", nil] allowLoginUI:YES
                              completionHandler:^(FBSession *session,
                                                  FBSessionState status,
                                                  NSError *error) {
                                  if (session.isOpen) {
                                      UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Success!" message:@"You logged in" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"Ok", nil];
                                      [alertView show];
                                  }
                                  else if(status == FBSessionStateClosedLoginFailed) {
                                      UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Oops!" message:@"Loggin failed" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"Ok", nil];
                                      [alertView show];
                                  }
                              }];

07-24 17:44
查看更多