FBSDKLoginManager失败,错误代码为 - 308

时间:2015-06-18 18:50:49

标签: facebook facebook-login

我们正在使用 FBSDKLoginManager 和我们自己的用户界面登录facebook。但是,有时登录失败,错误代码为308

根据文档,原因是 - FBSDKLoginBadChallengeString,我在互联网上搜索了找出原因,但没有运气。

有关此错误发生原因及解决方法的任何解释?

4 个答案:

答案 0 :(得分:1)

这就是我复制和解决com.facebook.sdk.login错误308的方法。

用户A登录到Facebook,然后登录到我的应用程序,最后使用流行的:

退出我的应用程序
func logOutFromFacebook(){

   if (FBSDKAccessToken.currentAccessToken() != nil){

           let loginManager = FBSDKLoginManager()
           loginManager.logOut()
    }
}

现在用户B登录Facebook,登录到我的应用程序,com.facebook.sdk.login错误308显示。

如果我重新安装应用程序,新用户可以毫无问题地登录,但我肯定不希望每次有帐户切换时重新安装应用程序。

解决此问题的解决方案是使用FBSDKAccessToken.setCurrentAccessToken(nil),如下所示:

func logOutFromFacebook(){

   if (FBSDKAccessToken.currentAccessToken() != nil){

     FBSDKAccessToken.setCurrentAccessToken(nil)

        By itself I had no use for it, maybe you might want to uncomment.
        //   let loginManager = FBSDKLoginManager()
        //   loginManager.logOut()

    }
}

希望它有所帮助!

答案 1 :(得分:0)

如何解决 iOS10 Facebook登录的问题

Error OSStatus -10814 occures when canOpenURL: can't find any application, that can open this URL (actually, Facebook trying to find their application by calling canOpenURL: with argument "fbauth2:/"). Printing happens inside of function, so you can't do anything with that. But if you will run your application on device with installed Facebook app, you will not see this error.

Error 308 occures because of the situation, when value, stored in keychain is not equal to value, that is stored in facebook completion parameters (for more information you can check -[FBSDKLoginManager completeAuthentication:expectChallenge:]).

It happens because Apple changed the way of working with keychain in iOS 10. To fix this issue you simply should go to **Targets**->**Capabilities** and **enable keychain sharing** (it enables access to keychain for your app): 

之后,您可以获取Facebook的数据。

希望它能帮到你。

感谢Mandeep Singh

答案 2 :(得分:0)

使用以下吊舱

  pod 'FacebookCore', '~> 0.5.0'
  pod 'FacebookLogin', '~> 0.5.0'
  pod 'FacebookShare', '~> 0.5.0'
  pod 'FBSDKCoreKit', '~> 4.37.0'
  pod 'FBSDKLoginKit', '~> 4.37.0'
  pod 'FBSDKShareKit', '~> 4.37.0'

还要在登录前在FBSDKLoginManager上调用logOut()

答案 3 :(得分:0)

使用以下吊舱

 pod 'FacebookCore', '~> 0.5.0'
 pod 'FacebookLogin', '~> 0.5.0'
 pod 'FacebookShare', '~> 0.5.0'
 pod 'FBSDKCoreKit', '~> 4.37.0'
 pod 'FBSDKLoginKit', '~> 4.37.0'
 pod 'FBSDKShareKit', '~> 4.37.0'

还要在登录前在FBSDKLoginManager上调用logOut()

相关问题