我正在尝试创建一个函数与iOS facebook sdk,我将能够登录,如果我登录,我将能够看到nslog字符串“已登录”。然而,我根本看不到它的字符串。此外,在按下按钮、查看我的Facebook应用程序和按下ok继续操作方面,登录似乎工作得很好。有人能告诉我我哪里做错了吗?
-(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");
}
}发布于 2013-07-12 05:27:19
我怀疑您至少错过了步骤2d,将openURL连接回Facebook SDK:
https://developers.facebook.com/docs/tutorials/ios-sdk-tutorial/authenticate/
..。也就是说,你很容易错过更多。如果你在登录后再次看到你的应用程序,那么我怀疑你已经将网址方案添加到了你的Info.plist中,否则也要检查一下。
https://stackoverflow.com/questions/14882773
复制相似问题