简体   繁体   English

FB.login没有为HTML5 iOS网络应用程序触发

[英]FB.login not firing for HTML5 iOS web app

This is for the non native solution, just a responsive website I'm building. 这是针对非本机解决方案,只是我正在构建的响应式网站。 Everything works fine in the browser, but nothing happens when I call FB.login(); 在浏览器中一切正常,但是当我调用FB.login()时没有任何反应;

$(function() {
   $.getScript("https//connect.facebook.net/en_US/all.js", function() {

        FB.init({
            appId      : fbAppId,
            status     : true,
            cookie     : true,
            oauth      : true
        });

        alert(FB); // [object object]

        FB.getLoginStatus(function(response) {
            alert(response.status);
            // if the iOS simulator is logged into facebook
            // this says "connected"

            // if the iOS simulator is NOT logged in
            // it says "unknown"
        });

        FB.login(function(res) {
            // never gets here on iOS simulator
            // works fine on browsers
        });

   }
});

The problem is when I'm not logged into facebook, i'm trying to get the app to pop open the facebook looking screen. 问题是,当我没有登录到Facebook时,我正试图让应用程序弹出facebook看屏幕。 It never gets inside of FB.login, even though the same code works in the browser. 它永远不会进入FB.login,即使相同的代码在浏览器中工作。

Thanks to anyone who can help! 感谢任何能提供帮助的人!

It turns out, that you can't call FB.init and then FB.login() on the mobile browser. 事实证明,你不能在移动浏览器上调用FB.init然后调用FB.login()。 I was trying to save loading the SDK until the user needed to login, but I guess I have to just use hover intent or something else. 我试图保存加载SDK直到用户需要登录,但我想我只需要使用悬停意图或其他东西。

Once I loaded the SDK on page load, then did FB.login() onclick() that was enough to get it working. 一旦我在页面加载时加载了SDK,那么FB.login()onclick()就足以让它工作了。

PITA PITA

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

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