简体   繁体   English

iPhone上的Facebook登录按钮

[英]Facebook login button on iPhone

I'm using the Facebook JS SDK for my website's login and I have this code on my page 我正在使用Facebook JS SDK进行网站登录,我的页面上有这个代码

<div id="fb-root"></div>

<script type="text/javascript">
    window.fbAsyncInit = function() {
        FB.init({"appId":"xxxxxxxxxxxxxx","xfbml":true,"oauth":true,"status":false,"cookie":true,"logging":false});
        onFbInit();
    };

    (function() {
        var e = document.createElement('script'); 
        e.src = document.location.protocol + "\/\/connect.facebook.net\/en_US\/all.js";
        e.async = true;
        document.getElementById('fb-root').appendChild(e);
    }());
</script>

    <fb:login-button scope="email" autologoutlink="false">Log in using Facebook</fb:login-button>

<script>
    function goLogIn(){
        window.location = "/fb/login_check";
    }

    function onFbInit() {.
        if (typeof(FB)!= 'undefined' && FB!= null ) {
            FB.Event.subscribe('auth.statusChange', function(response) {
                setTimeout(goLogIn, 500);
            });
        }
    }
</script>   

This works fine on all desktop browsers and iPad, but on Mobile Safari on iPhone/iPod the login button opens a new tab but does not post back to the page and therefore callback is not called. 这适用于所有桌面浏览器和iPad,但在iPhone / iPod上的Mobile Safari上,登录按钮会打开一个新选项卡,但不会回发到页面,因此不会调用回调。 When I click the Facebook login button on my login (or register) page, it opens the Facebook oauth login page in a new tab, I enter my Facebook login details and the Facebook tab closes but the focus does not return back to my login page. 当我点击登录(或注册)页面上的Facebook登录按钮时,它会在新选项卡中打开Facebook oauth登录页面,我输入我的Facebook登录详细信息并关闭Facebook标签,但焦点不会返回到我的登录页面。 I don't have a Mac to use the inspector but a friend says that they got this error in the debug console "Unable to post message to https://m.facebook.com/ . Recipient has origin https://www.facebook.com/ " 我没有Mac使用检查器,但朋友说他们在调试控制台中收到此错误“无法将消息发布到https://m.facebook.com/ 。收件人来源https:// www。 facebook.com/

To reproduce the steps: 要重现以下步骤:

  1. Go to http://eventstagr.am/register on iPhone (Safari Mobile and Chrome both don't work) 转到iPhone上的http://eventstagr.am/register(Safari Mobile和Chrome都不起作用)
  2. Click register 点击注册

    • EXPECTED : The Facebook tab should close and call the javascript callback function on the register page 预期 :Facebook标签应关闭并调用注册页面上的javascript回调函数
    • ACTUAL : The Facebook tab closes and focus does not return to the register page ACTUAL :Facebook标签关闭,焦点不会返回到注册页面

Alternatively if you already have an account, repeat the steps above but from http://eventstagr.am/login , the results are the same. 或者,如果您已经拥有一个帐户,请重复上述步骤,但是从http://eventstagr.am/login开始 ,结果是相同的。

Have you registered your app for mobile web login? 您是否注册了移动网络登录应用程序? You can do this ( per Facebook's instructions ) by going into the Facebook app settings . 您可以通过进入Facebook应用设置来执行此操作( 根据Facebook的说明 )。

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

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