Facebook Ios sdk登录
问题描述:
我想创建一个功能与iOS的Facebook的Facebook的,我将能够登录,如果我登录,我将能够看到nslog字符串“登录”。但是我根本没有看到它的字符串。此外,登录似乎在推按钮和看到我的Facebook应用程序方面工作正常,并按OK继续。有人能告诉我我做错了什么吗?Facebook Ios sdk登录
-(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");
}
}
答
我怀疑你已经错过了至少步骤2d,接线的OpenURL回到Facebook的SDK:
https://developers.facebook.com/docs/tutorials/ios-sdk-tutorial/authenticate/
...这么说,你可以很容易地错过了。如果您在登录后再次看到您的应用,那么我怀疑您已将URL方案添加到Info.plist中,否则请检查该方案。