[英]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.