我有这段代码,它解决了在Parse.com JavaScript中使用Facebook登录工作流时用户的Facebook身份验证的Chrome移动端问题
https://parse.com/docs/js/guide#users-facebook-users
// fix iOS Chrome
if( navigator.userAgent.match('CriOS') )
window.open('https://www.facebook.com/dialog/oauth?client_id='+490518664444605+'&redirect_uri='+ document.location.href +'&scope=email,public_profile', '', null);
else
Parse.FacebookUtils.logIn(null, {
//scope: 'email,public_profile'
});可以在https://parse.com/docs/js/guide#users-facebook-users中找到此解决方法的来源
我不能理解的是,我可以在哪里插入这个修复现有的代码?我已经尝试了代码块中的几个位置,但到目前为止还无法达到预期的结果
有没有人能提个建议?
现有代码
//check user session and refresh it
var uri = encodeURI('http://xxxxcom/home.html');
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
//user is authorized
document.getElementById('loginBtn').style.display = 'none';
getUserData();
} else {
//user is not authorized
}
});
};
//load the JavaScript SDK
(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 = "//connect.facebook.net/en_US/all.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
//add event listener to login button
document.getElementById('loginBtn').addEventListener('click', function() {
//do the login
var uri = encodeURI('http://xxxxx.com/home.html');
Parse.FacebookUtils.logIn(null, {
success: function(user) {
if (!user.existed()) {
window.location.href=uri;
} else {
window.location = encodeURI("https://www.facebook.com/dialog/oauth?client_id=xxxxxxx&redirect_uri="+uri+"&response_type=token");
}
},
error: function(user, error) {
}
});
}, false);发布于 2016-02-26 01:15:21
我有一个在谷歌浏览器中登录ios facebook网站的解决方案。实际上,问题出在ios中的google chrome,当我们点击facebook的登录按钮时,issue中的window.open在内部显示为空。
有两种解决方案-
First-要么检查它是ios(chrios)中的chrome,然后生成自定义登录屏幕(仍然没有机会,我们会正确)。
Second-我用过的东西。是使用facebook登录,从反手创建一个api点击将填充facebook屏幕,然后当登录完成后,它将重定向到您的服务器,从那里您将重定向到您的网站页面与facebook数据。
的另一个好处是,它的是,你可以创建2个网站的同一网站所有者(你不能设置两个网站的网址在脸书开发者帐户) .In这种方式,你可以创建多个网站脸书登录与相同的脸书appid。
https://stackoverflow.com/questions/31253779
复制相似问题