简体   繁体   English

IOS中的Facebook登录可以在模拟器上运行,但不能在安装了本机应用程序的设备上运行

[英]Facebook login in IOS works on emulator but not on device with native app installed

Facing the following problem: need to perform Facebook login in IOS 7. The thing goes right on the emulator but when running it on device with native app installed, the session give not permission to perform the login. 面临以下问题:需要在IOS 7中执行Facebook登录。该操作在模拟器上正常进行,但是在安装了本机应用程序的设备上运行时,会话不授予执行登录的权限。

Using the code to create session: 使用代码创建会话: 在此处输入图片说明

The checarLogin method works like: checarLogin方法的工作方式如下:

在此处输入图片说明

I have googled to find it and figured out that the device settings that control the permissions of Facebook app works differently in the two cases: 我已经用谷歌搜索找到它,并发现控制Facebook应用程序权限的设备设置在两种情况下的工作方式不同:

Emulator give the permission with no issues: 仿真器给予权限没有问题:

在此处输入图片说明

The following image was took from emulator too, but only to illustrate the way the device works by default: 下图也来自仿真器,但仅用于说明设备默认的工作方式:

在此处输入图片说明

So the question is: there is other way to handle the login when running in a real device with native Facebook app installed and make it accept the permissions without the need to change the iphone settings? 所以问题是:在安装了本地Facebook应用程序的真实设备中运行时,还有其他方法可以处理登录,并使其无需更改iPhone设置即可接受权限?

This is what I use in my apps, you have to allow the login UI. 这是我在应用程序中使用的,您必须允许登录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);
        }];

} }

And that's how you use it 这就是你使用它的方式

        [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

            }
        }];

I faced a similar problem, and this is what worked for me: 我遇到了类似的问题,这对我有用:

https://stackoverflow.com/a/12069251/2407717 https://stackoverflow.com/a/12069251/2407717

A colleague changed some of our project settings, including the Bundle Identifier , so it wasn't matching the iOS Bundle ID on Facebook anymore. 一位同事更改了我们的某些项目设置,包括Bundle Identifier ,因此它不再与Facebook上的iOS Bundle ID相匹配。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Facebook原生登录即使安装在设备中也不会打开Facebook应用程序? - Facebook native login is not opening facebook app even if it's installed in device? 安装Facebook应用程序的Facebook SDK iOS登录 - Facebook SDK iOS login with Facebook app installed Facebook IOS SDK登录在模拟器上有效,而不在设备上有效 - Facebook IOS SDK Login works on simulator, not on device iOS:使用Facebook登录并打开Native Facebook应用程序 - iOS : Login with Facebook and open Native Facebook app 在设备上安装FB Native App时无法授权使用Facebook ios sdk v3 - unable to authorize using Facebook ios sdk v3 when FB Native App is installed in the device 应用程序配置错误,安装Facebook登录IOS Facebook应用程序 - App is misconfigured for Facebook login IOS Facebook app installed 适用于iOs的phoneGap应用程序:如果应用程序在xCode设备模拟器中有效 - phoneGap app for iOs: if application works in xCode device emulator Firebase Facebook从iOS模拟器中的Ionic(Cordova)应用程序登录 - Firebase Facebook Login from Ionic (Cordova) app in iOS Emulator Facebook 登录 Swift 在设备上不起作用(但在 IOS 模拟器上起作用) - Facebook Login Swift don't works On Device (But do on IOS Simulator) 在iOS 9中,本地Facebook应用程序无法通过Facebook登录打开 - Native Facebook app does not open with Facebook login in iOS 9
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM