Facebook登录弹出受阻 [英] Facebook login popup blocked

查看:1020
本文介绍了Facebook登录弹出受阻的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是Facebook应用程序,以我的用户进行身份验证,但如果用户没有登录Facebook的(我与检查它FB.getLoginStatus())我给他一个按钮来登录。问题是,在弹出被阻止所有的时间。我不知道为什么,因为我注册了Facebook帐号登录行动 NG-点击

I am using a Facebook app to authenticate my users, but if the user is not logged in to Facebook (I am checking it with FB.getLoginStatus()) I show him a button to log in with. The problem is that the pop-up gets blocked all the time. I have no idea why, since I am registering the Facebook log in action on ng-click.

  <button type="button" ng-click="login()">Log in via Facebook</button>

  ...

  $scope.login = function() {
            FB.getLoginStatus(function(response) {
                if (response.status === 'connected') {
                    $scope.userId = response.authResponse.userID
                    loginSuccess()
                } else
                    FB.login(function(response) {
                        if (response.authResponse) {
                            $scope.userId = response.authResponse.userID
                            loginSuccess()
                        } else {
                            alert('You need to log in and authorize the app, otherwise you won\'t be able to take the quiz!')
                        }
                    })
            })
        }

任何帮助吗?

推荐答案

FB.getLoginStatus 应该在页面加载时用来检查用户是否授权并刷新用户令牌。您可以之后 FB.init 使用它,并保存用户ID,如果他在被记录下来。

FB.getLoginStatus should be used on page load to check if the user is authorized and to refresh the User Token. You can use it right after FB.init and store the User ID if he is logged in.

FB.login 必须直接在用户交互使用,你在使用异步它(!) FB.getLoginStatus <回调函数/ code>,而不是直接在按钮上的用户点击。

FB.login must be used directly on user interaction, you are using it in the asynchronous (!) callback function of FB.getLoginStatus and not directly when the user clicks on the button.

例如: http://www.devils-heaven.com/facebook -javascript-SDK-登录/

这篇关于Facebook登录弹出受阻的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆