I am developing a canvas app and got it working as required in all browsers apart from IE 7/8 where I cannot get the app to auto redirect to the Facebook login screen if users are not already logged into Facebook.
I suspect that IE is not getting the state of the users through getLoginStatus method and therefore cannot fire the javascript redirect, and because of this the remove the app functionality is also not working.
I have ran the code through a online JS lint tool and have tidied a few things up and tried again but having no luck
If I try this outside of facebook e.g https://mydomain.com/directory, the JS SDK works perfectly and redirects to Facebook login page but will not do the same within the Facebook iframe
I have noticed that within the Facebook iframe the system cannot get the browser mode and uncertain whether this would have a bearing
Here is my complete code
$(document).ready( function() {
//Facebook JS SDK
window.fbAsyncInit = function () {
FB.init({
appId: 'xxxxxxxxxxxxxxxxx',
channelUrl: '//www.mydomain.co.uk/facebook-notes/channel.html',
// Channel File
cookie: true,
xfbml: true,
oauth: true,
status: true
});
FB.getLoginStatus(function (response) {
if (response.status === 'connected') {
//alert('hello');
$('a#remove-app').click(function () {
var request = response.authResponse.accessToken;
$("#dialog:ui-dialog").dialog("destroy");
$("#dialog-confirm").dialog({
height: 140,
modal: true,
position: [236, 101],
buttons: {
"Yes": function () {
if (request) {
$.ajax({
url: 'https://graph.facebook.com/me/permissions',
type: 'GET',
data: 'method=delete&access_token=' + request,
dataType: 'jsonp',
success: function (response) {
top.location.href = 'http://facebook.com';
}
});
}
},
Cancel: function () {
$(this).dialog("close");
}
}
});
return false;
});
} else {
//alert('user not logged in');
var oauth_url = 'https://www.facebook.com/dialog/oauth/';
oauth_url += '?client_id=xxxxxxxxxxxxxxx';
oauth_url += '&redirect_uri=' + encodeURIComponent('https://apps.facebook.com/app_name/');
oauth_url += '&scope=email';
window.top.location = oauth_url;
}
},
true);
$('a#invite-a-friend').click(function () {
sendRequestViaMultiFriendSelector();
});
// Multi friend selector for Facebook
function sendRequestViaMultiFriendSelector() {
FB.ui({
method: 'apprequests',
message: 'Come and join the app on Facebook'
});
}
function requestCallback(response) {
alert (response);
}
};
// Load the SDK Asynchronously
(function (d) {
var js,
id = 'facebook-jssdk',
ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {
return;
}
js = d.createElement('script');
js.id = id;
js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
});
I would appreciate any help