[英]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. 这个问题长期以来一直困扰着我,我似乎无法找到解决方案,我的Facebook Developer面板中的所有设置都已正确配置,站点URL,应用域和OAuth URL。
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: 当我在iPhone上运行我的应用程序(我通过iTunes安装它)并单击身份验证按钮时,我已成功提示此屏幕:
However, after logging in, I am faced with a blank white screen instead of being redirected to my main.html
page. 但是,登录后,我面临一个空白的白色屏幕,而不是被重定向到我的
main.html
页面。
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: 我正在使用OpenFB插件以及Parse和Facebook Graph API来验证和存储我的用户数据,这是我的登录代码:
login.html: 的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: 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. 注意:我已将
main.html
, login.html
和oauthcallback.html
添加到我面板上的Valid OAuth重定向URI列表中。
Check that your site is using SSL with a valid certificate. 检查您的站点是否使用带有效证书的SSL。
There might be an error trying to redirect from a non-secure site to an encrypted site. 尝试从非安全站点重定向到加密站点时可能会出错。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.