简体   繁体   中英

Facebook login on cordova app shows blank white screen

This problem has been bugging me for a long time and I can't seem to find the solution, all the settings in my Facebook Developer panel are configured correctly, Site URL, App Domain and OAuth URLs.

When I run my app on my iPhone (I have it installed through iTunes) and click the authentication button I am successfully prompted with this screen:

在此输入图像描述

However, after logging in, I am faced with a blank white screen instead of being redirected to my main.html page.

I am using the OpenFB plugin along with Parse and the Facebook Graph API to authenticate and store my users data, here is my login code:

login.html:

$('.facebookLogin').click(function(){
  Parse.User.logOut(); // log current user out before logging in 
  login();
});

function login() {
  openFB.login(function(response) {
    if(response.status === 'connected') {

      console.log('Facebook login succeeded');

      Parse.FacebookUtils.logIn("email", { // permission request to use email
        success: function(user) {
          if (!user.existed()) {
             FB.api('/me', function(response) {
                var firstName = response.first_name;
                var lastName = response.last_name;
                var email = response.email; 
                var user_id = response.id;

                user.set("firstName",firstName);
                user.set("lastName",lastName);
                user.set("email",email);
                user.save();
             }); 
             window.location.href= "main.html";
          } 
          else {
             window.location.href= "main.html";
          } 
        }, 
        error: function(user, error) {
          alert("User cancelled the Facebook login or did not fully authorize.");
        }
     });  
    } 
    else {
      alert('Facebook login failed: ' + response.error);
    }
  }, {scope: 'email'}); 
} 

oauthcallback.html:

<html>
<body>
<script>
   // redirects to main page
   window.location.href= "main.html";
</script>
</body>
</html>

Note: I have added main.html , login.html and oauthcallback.html to the Valid OAuth redirect URIs list on my panel.

Check that your site is using SSL with a valid certificate.

There might be an error trying to redirect from a non-secure site to an encrypted site.

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