ios - IOS 中的 Facebook 登录可以在模拟器上使用,但不能在安装了 native 应用程序的设备上使用

标签 ios iphone facebook facebook-sdk-3.0

面临以下问题:需要在 IOS 7 中执行 Facebook 登录。模拟器上一切正常,但在安装了 native 应用程序的设备上运行时, session 不允许执行登录。

使用代码创建 session : enter image description here

checarLogin 方法的工作原理如下:

enter image description here

我通过 Google 搜索找到了它,并发现控制 Facebook 应用程序权限的设备设置在这两种情况下的工作方式不同:

模拟器授予权限,没有任何问题:

enter image description here

下面的图片也是从模拟器中获取的,但只是为了说明设备的方式 默认工作:

enter image description here

所以问题是:在安装了 native Facebook 应用程序的真实设备中运行时,还有其他方法可以处理登录并使其接受权限,而无需更改 iPhone 设置吗?

最佳答案

这是我在我的应用程序中使用的,您必须允许登录 UI。

- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI completionHandler:(FBSessionStateHandler)handler {

// We pass this permissions array into our request.
// I only request email, but there are many more options.
//
NSArray *permissions = @[@"email", @"basic_info"];

return [FBSession
        openActiveSessionWithReadPermissions:permissions
        allowLoginUI:allowLoginUI
        completionHandler:^(FBSession *session,
                            FBSessionState state,
                            NSError *error) {

            if (handler)
                handler(session, state, error);
        }];

}

这就是你如何使用它

        [self openSessionWithAllowLoginUI:YES completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {

            if (!error && status == FBSessionStateOpen) {
                NSString *token = session.accessTokenData.accessToken;

                // You're logged in!

            } else {

                // Something wrong happened

            }
        }];

关于ios - IOS 中的 Facebook 登录可以在模拟器上使用,但不能在安装了 native 应用程序的设备上使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21632043/

相关文章:

ios - 在 Xcode 7 中为所有 iPhone 设备准确设置 Assets

iphone - ModalViewController 不在窗口层次结构中

iOS FBLoginView : the user is not allowed to see this application per the developer set configuration

java - 如何在数据库中实现 Facebook 好友模块?

ios - 返回所有关注的 Instagram API 哈希不再有效

ios - React-native 无法访问 Parse 数据

iphone - UIImageView的CALayer的anchorPoint "accessing unknown component of property"错误

ios - 如何在 iOS 应用程序中获取 YouTube 数据?

ios - 将 Xcode 6.3 重置为原始状态

facebook - 应用程序身份验证后重定向到 Facebook 选项卡的正确方法?