简体   繁体   English

无法使用iOS SDK和本机Facebook应用程序授权Facebook

[英]Can't auth to Facebook with iOS SDK and native Facebook application

What I have and what're problems occurred: 我有什么,发生了什么问题:

  1. I've one Facebook account with game application (every day people's playing) 我有一个Facebook帐户的游戏应用程序(每天人们在玩)
  2. I've one more Facebook account with test application, that created recently with default settings. 我还有一个带有测试应用程序的Facebook帐户,该帐户最近使用默认设置创建。
  3. I've native Facebook application on my iPod 我在iPod上使用原生Facebook应用程序
  4. I'm developing iOS application which uses Facebook iOS SDK. 我正在开发使用Facebook iOS SDK的iOS应用程序。

Invalid flow: 流量无效:

If I use App ID/API Key from first application, I open my application and trying to login. 如果我在第一个应用程序中使用App ID / API Key,我会打开我的应用程序并尝试登录。 Facebook SDK opens native FB application and show me that screen Facebook SDK打开本机FB应用程序并向我显示该屏幕 在此输入图像描述

I press OK and go back to my iOS with such error and without access token: 我按OK然后返回我的iOS,出现此类错误并且没有访问令牌:

(NSError *) $0 = 0x001710f0 Error Domain=com.facebook.sdk Code=2 "The operation couldn’t be completed. (com.facebook.sdk error 2.)" UserInfo=0x16d4b0 {com.facebook.sdk:ErrorLoginFailedOriginalErrorCode=210}

Valid flow: 有效流程:

If I use App ID/API Key from second (test) application, I open my application and trying to login. 如果我从第二个(测试)应用程序使用App ID / API Key,我打开我的应用程序并尝试登录。 Facebook SDK opens native FB application and show me that screen Facebook SDK打开本机FB应用程序并向我显示该屏幕 在此输入图像描述

I press OK and go back to my iOS with valid access token. 我按OK然后使用有效的访问令牌返回我的iOS。

Settings of applications are the same, I didn't see any differences. 应用程序的设置是一样的,我没有看到任何差异。 This problem occurred if I have native Facebook application. 如果我有本机Facebook应用程序,则会出现此问题。 If I haven't it, Facebook SDK opens browser and authorization will be successful with first and second App ID. 如果我没有,Facebook SDK将打开浏览器,授权将成功使用第一个和第二个App ID。

If someone had such problem, please help. 如果有人有这样的问题,请帮忙。 Thanks a lot. 非常感谢。

I solved the issue. 我解决了这个问题。

Actually after changing here and there I found my bundle id was not matching. 事实上,在这里和那里更改后,我发现我的捆绑ID不匹配。 I have kept the bundle id same in the following 3 places and it worked: 我在以下3个地方保持捆绑ID相同并且它有效:

  1. The bundle identifier of your project. 项目的包标识符。
  2. In your FB a/c the filed named "iOS Bundle ID:" under head Native iOS App. 在您的FB a / c中,名为“iOS Bundle ID:”的文件名为Native iOS App。
  3. The notification string value in your AppDelegate.m AppDelegate.m中的通知字符串值

    NSString *const FBSessionStateChangedNotification = @"yourbundleid:FBSessionStateChangedNotification";

I found that I received the same error when I requested the permission: "offline_access". 我发现在我请求权限时收到了同样的错误:“offline_access”。 When I stopped asking for this permission, the error went away. 当我停止要求此权限时,错误就消失了。

I had the same problem, and my BundleId were both correct, on FB and in my project. 我有同样的问题,我的BundleId在FB和我的项目中都是正确的。

Check that your FB App is enabled in Settings -> Facebook. 检查您的FB应用程序是否在设置 - > Facebook中启用。 Mine was disabled (even though I don't remember disabling it) and once I enabled it, it was fixed. 我被禁用(即使我不记得禁用它),一旦我启用它,它就被修复了。

In my test process, I've added and removed my FB App several times from my FB Account, which is linked with my iPhone. 在我的测试过程中,我已经从我的FB帐户中添加和删除了我的FB应用程序几次,该帐户与我的iPhone相关联。 It may explain why, magically, my app was disabled. 它可以解释为什么,神奇地,我的应用程序被禁用。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM