xcode FBSession 的 Facebook iOS SDK 3.0 登录教程问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11925987/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 01:13:05  来源:igfitidea点击:

Facebook iOS SDK 3.0 Login Tutorial Issue with FBSession

objective-ciosxcodefacebook

提问by Andre Elijah

I am currently trying to put together an app - with the foundation of it being (hopefully) built on the Facebook iOS SDK 3.0 tutorial.

我目前正在尝试组合一个应用程序 - 它的基础(希望)建立在 Facebook iOS SDK 3.0 教程上。

The tutorial I am following is located at: http://developers.facebook.com/docs/tutorials/ios-sdk-tutorial/authenticate/

我正在关注的教程位于:http: //developers.facebook.com/docs/tutorials/ios-sdk-tutorial/authenticate/

I have found there to be a few changes throughout the various SDK versions from Facebook when it comes to the final release.

我发现 Facebook 的各种 SDK 版本在最终版本中都有一些变化。

However I do have one final issue before the code will compile:

但是,在代码编译之前,我还有最后一个问题:

"No known class method for selector 'sessionOpenWithPermissions:completionHandler:'"

“没有已知的选择器类方法 'sessionOpenWithPermissions:completionHandler:'”

This error refers to the following code:

此错误是指以下代码:

- (void)openSession
{
    [FBSession sessionOpenWithPermissions:nil completionHandler:
     ^(FBSession *session, FBSessionState state, NSError *error) {
         [self sessionStateChanged:session state:state error:error];
     }];    
}

When looking at the FBSession.h file in Xcode there is no mention of sessionOpenWithPermissions.

在 Xcode 中查看 FBSession.h 文件时,没有提到sessionOpenWithPermissions.

Can anyone please help me with regard to this? I am new to Objective-C/Xcode and am learning via trial by fire.

任何人都可以帮我解决这个问题吗?我是 Objective-C/Xcode 的新手,正在通过试验学习。

回答by Seb

I ran into the same issue, got my code working with the below change.

我遇到了同样的问题,让我的代码使用以下更改。

//REPLACE
[FBSession sessionOpenWithPermissions:nil
                    completionHandler: ^(FBSession *session, FBSessionState state, NSError *error) {
                        [self sessionStateChanged:session state:state error:error];
                    }];

//WITH
[FBSession openActiveSessionWithPermissions:nil
                               allowLoginUI:YES
                          completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
                              [self sessionStateChanged:session state:state error:error];
                          }];

If you alt click on the method you'll get more info on the parameters to pass. openActiveSessionWithPermissions options

如果您按住 Alt 单击该方法,您将获得有关要传递的参数的更多信息。 openActiveSessionWithPermissions 选项

回答by Ethan Mateja

It looks like the documentation has a bug. According the API Change log, that class method as been replaced.

看起来文档有一个错误。根据 API 更改日志,该类方法已被替换。

FBSession class method sessionOpenWithPermissions:completionHandler: has been removed, instead use the new openActiveSessionWithPermissions:allowLoginUI:completionHandler: class method.

FBSession 类方法 sessionOpenWithPermissions:completionHandler: 已被删除,而是使用新的 openActiveSessionWithPermissions:allowLoginUI:completionHandler: 类方法。

API Change log URL

API 更改日志 URL