facebook登录混合应用程序不在Android设备上工作

时间:2015-07-16 08:50:33

标签: android jquery facebook visual-studio-cordova facebook-authentication

我正在构建混合Android应用程序

我有一个facebook登录按钮

HTML CODE

   <!DOCTYPE html>
    <html>
        <head>
            <meta charset="utf-8">
            <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
            <title></title>
     <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
            <script src="js/app.js"></script>
        </head>
        <body>
        <div>Facebook login check</div>
        <fb:login-button scope="public_profile,email" onclick="checkLoginState();" class="">Login to Facebook   </fb:login-button>
                            <div id="status"></div>
    </html>

SCRIPT

function statusChangeCallback(response) {
    console.log('statusChangeCallback');
    console.log(response);
    if (response.status === 'connected') {
      testAPI();
    } else if (response.status === 'not_authorized') {
      document.getElementById('status').innerHTML = 'Please log into this app.';
    } else {
      document.getElementById('status').innerHTML = 'Please log into Facebook.';
    }
  }

  function checkLoginState() {
    FB.getLoginStatus(function(response) {
      statusChangeCallback(response);
    });
  }

  window.fbAsyncInit = function() {
  FB.init({
    appId: '1132355650113496',
    cookie     : true, 
    xfbml      : true, 
    version    : 'v2.3'
  });

  FB.getLoginStatus(function(response) {
    statusChangeCallback(response);
  });
  };


  (function(d, s, id) {
    var js, fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) return;
    js = d.createElement(s); js.id = id;
    js.src = "https://connect.facebook.net/en_us/sdk.js";
    fjs.parentNode.insertBefore(js, fjs);
  }(document, 'script', 'facebook-jssdk'));


  function testAPI() {
    console.log('Welcome!  Fetching your information.... ');
    FB.api('/me', function(response) {
      console.log('Successful login for: ' + response.name);
      document.getElementById('status').innerHTML =
        'Thanks for logging in, ' + response.name + '!';
    });
  }

我在localhost

中部署它时效果很好

enter image description here

但是当我在Android手机中安装并打开它时,登录按钮没有显示

在本地主机中,我遇到类似的问题,我将本地主机添加到有效的oauth重定向网址,它开始工作 enter image description here

我不知道我应该怎么做才能在android设备中使这个工作

0 个答案:

没有答案