I'm trying to use parse.com Facebook SDK to allow my users to login to my site using the Fb login button.
I have this working fine for desk browsers and Safari, but there is a known issue with ios Chrome that creates the error discussed here.
My investigations have lead me to conclude that is the Parse.FacebookUtils.logInclass that is causing the Facebook pop up window to open, is that correct?
If so, is it not possible to open this as a page and not a pop up? which would avoid the above error.
I've built a workaround that works for a standard Facebook login, but doesn't work for Parse. Not sure if its possible to use this? Information for this work around came from here.
I've also seen the answer from Rahul here as a potential solution, but I'm unsure how to implement it
Any help would be gratefully received as I've been stuck on this for ages.
function getUserData() {
FB.api('/me', function(response) {
document.getElementById('response').innerHTML = 'Hello ' + response.name;
});
}
window.fbAsyncInit = function() {
//SDK loaded, initialize it
Parse.FacebookUtils.init({
appId : '12345',
xfbml : true,
version : 'v2.3'
});
//check user session and refresh it
var uri = encodeURI('http://mysite123.com/user_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() {
var ABSOLUTE_URI = "http://mysite123.com/user_home.html";
var FB_ID = "12345";
// Open your auth window containing FB auth page
// with forward URL to your Opened Window handler page (below)
var redirect_uri = "&redirect_uri=" + ABSOLUTE_URI;
var scope = "&scope=public_profile,email,user_friends";
var url = "https://www.facebook.com/dialog/oauth?client_id=" + FB_ID + redirect_uri + scope;
// notice the lack of other param in window.open
// for some reason the opener is set to null
// and the opened window can NOT reference it
// if params are passed. #Chrome iOS Bug
window.open(url);
function fbCompleteLogin(){
Parse.FacebookUtils.logIn(null, {
success: function(user) {
if (!user.existed()) {
alert("User signed up and logged in through Facebook!");
} else {
alert("User logged in through Facebook!");
}
},
error: function(user, error) {
alert("User cancelled the Facebook login or did not fully authorize.");
}
});
}
function requireLogin(callback){
FB.getLoginStatus(function(response) {
if (response.status != "connected"){
showLogin();
}else{
checkAuth(response.authResponse.accessToken, response.authResponse.userID, function(success){
// Check FB tokens against your API to make sure user is valid
});
}
});
}
}, false);