我正在尝试使用 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");
}
}