简体   繁体   English

在iOS-SDK v 4.18.0中从未触发过Facebook登录回调

[英]Facebook login callback never fired in iOS-SDK v 4.18.0

I am implementing Facebook login for my iOS application in Xcode 8.1, with Swift3. 我正在使用Swift3在Xcode 8.1中为我的iOS应用程序实现Facebook登录。 The operation is simply done with the following function: 只需使用以下功能即可完成该操作:

[loginManager logInWithReadPermissions:@[@"email"]
                    fromViewController:self
                               handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
// my callback logic
 }];

(I got this code snippet from the Facebook docs . I am not on my work computer right now; because of that, it is obj-c) (我从Facebook文档中获得了此代码段。我现在不在我的工作计算机上;因此,它是obj-c)

I also implemented everything perfectly, regarding AppDelegate like methods of the Facebook login SDK, Info.plist key-values etc. 我还完美地实现了所有功能,例如AppDelegate例如Facebook登录SDK的方法, Info.plist键值等。

When the user has the Facebook app installed, everything works fine. 当用户安装了Facebook应用程序时,一切正常。

However, when the user has no Facebook app installed, the callback of the former function is never invoked. 但是,如果用户未安装Facebook应用,则永远不会调用前一个函数的回调。 SafaroViewController shows up, the user logs in and either grants the permissions or rejects the request. SafaroViewController出现,用户登录并授予权限或拒绝请求。 And suddenly, SafariViewController disappears and my callback does not get called ( AppDelegate like methods of the Facebook login SDK get called). 突然之间, SafariViewController消失了,我的回调也没有被调用(像Facebook登录SDK的AppDelegate类的方法被调用)。

What might be the problem? 可能是什么问题?

Assign FBSDKLoginButton as the class of your button instead of UIButton and in your outlet too. 也将FBSDKLoginButton分配为按钮的类, 而不是 UIButton ,也应分配FBSDKLoginButton您的插座。 Then set the button delegate and permission in viewDidLoad . 然后在viewDidLoad设置按钮delegatepermission

@IBOutlet weak var faceBookLoginButton: FBSDKLoginButton!

// MARK: - View life cycle methods

override func viewDidLoad() {
    super.viewDidLoad()
    // Facebook Permissions
    faceBookLoginButton.readPermissions = ["email"]
    faceBookLoginButton.delegate = self
}

Thanks:) 谢谢:)

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

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