简体   繁体   中英

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

<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. 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. 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/ "

To reproduce the steps:

  1. Go to http://eventstagr.am/register on iPhone (Safari Mobile and Chrome both don't work)
  2. Click register

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

Alternatively if you already have an account, repeat the steps above but from http://eventstagr.am/login , the results are the same.

Have you registered your app for mobile web login? You can do this ( per Facebook's instructions ) by going into the Facebook app settings .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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