使用FBShareDialog时Facebook分享问题

时间:2016-06-13 12:44:58

标签: ios iphone xcode facebook

我已按照Facebook上的内容分享说明进行操作。 我的登录代码如下。我已成功使用以下代码登录。但是当我按下分享按钮时,它会打开对话框,其中它是默认(本机)应用程序并且具有不同的帐户登录。我的代码中是否有任何问题或者是Facebook的问题?

let loginManager = FBSDKLoginManager()
    loginManager.loginBehavior = .SystemAccount
    loginManager.logInWithPublishPermissions(["publish_actions"] , fromViewController: fromController) { (result, error) in

        if (error != nil)
        {
         completion (response: nil, error: error)
        }
        else if result.isCancelled
        {
            let errorMessage = NSError(domain: "Facebook Login cancelled", code: -1, userInfo: [NSLocalizedDescriptionKey : "Facebook login got cancelled"])
            print("Login cancelled")
            completion(response: errorMessage, error: nil)
        }
        else
        {
            completion(response: [NSLocalizedDescriptionKey : "Login Successfully"], error: nil)
        }

    }

这是我的分享代码:

let accessToken = FBSDKAccessToken.currentAccessToken()

    if (accessToken != nil)
    {
        if(FBSDKAccessToken.currentAccessToken().hasGranted("publish_actions"))
        {
            let fbCOntent = FBSDKShareLinkContent()
            fbCOntent.contentURL = NSURL(string: "https://www.facebook.com/FacebookDevelopers");

            // TODO: publish content.
            let dialog = FBSDKShareDialog()

            dialog.fromViewController = self
            dialog.shareContent = fbCOntent
            dialog.mode = .Native

            if !(dialog.canShow())
            {
                dialog.mode = .FeedWeb
            }
            dialog.show()

        }
        else {
            // login with publish permission
        }
    }

0 个答案:

没有答案