在iOS Chrome中使用白页的FB重定向问题

当我按下登录按钮时,我得到了Facebook页面,我必须允许我使用我的Facebook帐户.

在我授予权限后,它会重定向https://www.facebook.com/dialog/permissions.request显示一个空白页面.在Android上调用“window.FB.login”回调(参见下面的代码),我可以在其中获取信息并重定向用户,但在Windows Phone上它只显示该空白页面.当我进入我的Facebook页面时,我的网站已在应用列表中注册.所以注册确实正常.

解决方法

错误是由于facebook js文件的不安全加载引起的.

要在应用程序中集成Facebook应用程序,您必须按照Facebook应用程序文档中指示的步骤操作.

var fbApi = {
      init: function () {
      $.getScript(document.location.protocol + '//connect.facebook.net/en_US/all.js',function () {
        if (window.FB) {
            window.FB.init({
                appId: MY_APP_ID,status: true,cookie: true,xfbml: false,oauth: true,channelUrl: 'http://www.yourdomain.com/channel.html'
            });

        }
    });
    },login: function () {
    /// <summary>
    /// Login facebook button clicked
    /// </summary>
    log("login facebook button clicked");

    if (window.FB) {

        //Windows phone does not enter this method,Android and Iphone do
        window.FB.login(function (response) {

            if (response.status) {
                log('it means the user has allowed to communicate with facebook');

                fbAccesstoken = response.authResponse.accesstoken;
                window.FB.api('/me',function (response) {
                    //get information of the facebook user.
                    loginService.subscribeSocialUser(response.id,response.first_name,response.last_name,fbAccesstoken,"","FaceBook",fbSucces,fbFail);

                });
            } else {
                log('User cancelled login or did not fully authorize.');

            }
        },{ scope: 'email'
        });
    }

}
};

添加了频道URL以解决任何跨浏览器问题.
它应该指向一个html文件,它引用js如下:

<script src="//connect.facebook.net/en_US/all.js"></script>

如果在初始化Facebook.js时遇到错误,您将无法成功登录.

您可以同步或异步加载java脚本.

(function(d,debug){
     var js,id = 'facebook-jssdk',ref = d.getElementsByTagName('script')[0];
     if (d.getElementById(id)) {return;}
     js = d.createElement('script'); js.id = id; js.async = true;
     js.src = "//connect.facebook.net/en_US/all" + (debug ? "/debug" : "") + ".js";
     ref.parentNode.insertBefore(js,ref);
   }(document,/*debug*/ false));

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...