0

我正在尝试使用 iOS facebook sdk 创建一个可以登录的功能,如果我登录了,我将能够看到 nslog 字符串“登录”。但是我根本没有看到它的字符串。此外,在按下按钮和查看我的 Facebook 应用程序并按确定继续时,登录似乎工作正常。有人可以告诉我我做错了什么吗?

   -(IBAction)popButton:(id)sender {

   TUAppDelegate *appDelegate = (TUAppDelegate *)[[UIApplication sharedApplication] delegate];

// this button's job is to flip-flop the session from open to closed
if (appDelegate.session.isOpen) {
    // if a user logs out explicitly, we delete any cached token information, and next
    // time they run the applicaiton they will be presented with log in UX again; most
    // users will simply close the app or switch away, without logging out; this will
    // cause the implicit cached-token login to occur on next launch of the application
    [appDelegate.session closeAndClearTokenInformation];

} else {
    if (appDelegate.session.state != FBSessionStateCreated) {
        // Create a new, logged out session.
        appDelegate.session = [[FBSession alloc] init];
    }

    // if the session isn't open, let's open it now and present the login UX to the user
    [appDelegate.session openWithCompletionHandler:^(FBSession *session,
                                                     FBSessionState status,
                                                     NSError *error) {
        // and here we make sure to update our UX according to the new session state
        [self updateView];
    }];
}
  }
- (void)updateView{
// get the app delegate, so that we can reference the session property
  TUAppDelegate *appDelegate = (TUAppDelegate *)[[UIApplication sharedApplication] delegate];
if (appDelegate.session.isOpen) {
    NSLog(@"Logged In");

} else {
    NSLog(@"Not Logged In");
}
}
4

1 回答 1

0

我怀疑您至少错过了第 2d 步,将 openURL 连接回 Facebook SDK:

https://developers.facebook.com/docs/tutorials/ios-sdk-tutorial/authenticate/

...也就是说,您很容易错过更多。如果您在登录后再次看到您的应用程序,那么我怀疑您已将 URL 方案添加到您的 Info.plist,否则也要检查。

于 2013-07-11T21:27:19.273 回答