Ios Facebook登录按钮在登录后未关闭

Ios Facebook登录按钮在登录后未关闭,ios,swift,facebook,Ios,Swift,Facebook,我正在尝试创建facebook登录身份验证,但是当用户单击按钮打开浏览器并登录时,我一直遇到问题,但是当我登录并授予权限时,不会发生任何事情,也不会关闭浏览器并返回应用程序。另一件事是当我再次打开应用程序并检查令牌时,它返回nil,即使它应该已经登录 func loginButton(_ loginButton: FBSDKLoginButton!, didCompleteWith result: FBSDKLoginManagerLoginResult!, error: Error!) {

我正在尝试创建facebook登录身份验证,但是当用户单击按钮打开浏览器并登录时,我一直遇到问题,但是当我登录并授予权限时,不会发生任何事情,也不会关闭浏览器并返回应用程序。另一件事是当我再次打开应用程序并检查令牌时,它返回nil,即使它应该已经登录

func loginButton(_ loginButton: FBSDKLoginButton!, didCompleteWith result: FBSDKLoginManagerLoginResult!, error: Error!) {
    if ((error) != nil)
    {
        // Process error
    }
    else if result.isCancelled {
        // Handle cancellations
    }
    else {
        // If you ask for multiple permissions at once, you
        // should check if specific permissions missing
        if result.grantedPermissions.contains("email") && result.grantedPermissions.contains("public_profile") && result.grantedPermissions.contains("user_friends")
        {

        }
    }

}
ViewDidLoad

   //Check for access
    if (FBSDKAccessToken.current() != nil) {
        print("Logged in")
    } else {
        self.performSegue(withIdentifier: "GoToIntro", sender: self)
    }
appDelegate

private func application(application: UIApplication, openURL url: URL, sourceApplication: String?, annotation: AnyObject?) -> Bool {


    return FBSDKApplicationDelegate.sharedInstance().application(application, open: url, sourceApplication: sourceApplication, annotation: annotation)
}
Plist

    <dict>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>fb1645871657973243</string>
        </array>
    </dict>
</array>
<key>FacebookAppID</key>
<string>1645871657973243</string>
<key>FacebookDisplayName</key>
<string>testy</string>
<key>LSApplicationQueriesSchemes</key>
<array>
    <string>fbapi</string>
    <string>fb-messenger-api</string>
    <string>fbauth2</string>
    <string>fbshareextension</string>
</array>

循环流化床锅炉方案
fb1645871657973243
FacebookAppID
1645871657973243
FacebookDisplayName
易怒的
LSApplicationQueriesSchemes
fbapi
fb messenger api
fbauth2
fbshareextension

几天前,我用iOS 10和Swift 3实现了FBSDK,但不是很顺利。对我来说,最大的问题可能是你身上发生了什么——新的SDK想要在iPhone上打开facebook应用程序,但模拟器自然没有。对此的检查很简单-出现以下错误:

-canOpenURL: failed for URL: "fbauth2:/" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"
我有这个问题好几天了,直到我环顾四周,在苹果开发论坛上找到了答案。另一个可能的原因是您没有正确实现AppDelegate函数。旧的FBSDKApplicationDelegate.sharedInstance()应用程序(…)函数已弃用。经过一番搜索,我提出了以下对我有效的实现:

func application(_ app: UIApplication, open url: URL, options: [String : AnyObject] = [:]) -> Bool {
    FBSDKApplicationDelegate.sharedInstance().application(app, open: url, sourceApplication: options["UIApplicationOpenURLOptionsSourceApplicationKey"] as! String,
                                                          annotation: nil)
    return true
}

ViewDidLoad
方法中,您必须输入:

 yourLoginFacebookButton.delegate = self
在您的登录类中,您必须放置以下实现:

FBSDKLoginButtonDelegate

您是否为FB集成添加了AppDelegate方法?FB使用URL方案在浏览器和应用程序之间进行通信,这就是为什么你需要应用程序委派方法。你还必须在应用程序的plist中注册FB方案,以使其工作。我已经安装了plisti。我已经添加了我的应用程序委派。是的,我注意到了。您的方法被钩住了,正如您所说,您已经正确地配置了plist。也许只是为了确定,把你的plist的代码发布在这里,这样社区就可以看到是否缺少了什么?当然,在发布应用程序敏感数据之前,不要忘记隐藏这些数据