I am developing a Facebook canvas app.
Trying to login and authorize my app is working fine.
But this scenario doesn't work.
- I open my application canvas https://apps.facebook.com/
{appID}
- Click on
Continue as
button. - Popup will show and I click on
Continue As
... to authorize. - Every thing looks fine and it's redirecting to main.php
- I go to
app settings
and remove my app. Update: Also logoff all facebook; same result! - Here I am expecting
main.php
to alert me that the user removed app (deauthorized) then logoff - Nothing happen and user still in the page
Here is my code:
// Load the SDK asynchronously
(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/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}
(document, 'script', 'facebook-jssdk'));
window.fbAsyncInit = function () {
FB.init({
appId: '{APPID}',
cookie: true, // enable cookies to allow the server to access
// the session
xfbml: true, // parse social plugins on this page
version: 'v2.10', // use graph api version 2.8
status: true,
oAuth: true
});
//start coding
// here trying all types of events subscribe to check if something
// missing or if I am subscribing the wrong event
FB.Event.subscribe('auth.authResponseChange', function (response) {
alert("authResponseChange=" + response);
});
FB.Event.subscribe('auth.login', function (response) {
alert("login=" + response);
});
FB.Event.subscribe('auth.statusChange', function (response) {
alert("statusChange=" + response);
});
FB.getLoginStatus(function (response) {
alert("getLoginStatus=" + response);
});
};
function ReadPHPresponse(data, cmd) {
//TODO
}
// end coding
App environments:
- App in development mode
- Its running on localhost WAMP
- Tried everything I could to disable caching: WAMP, FB Calls,
stats:true
- In App setting I select the
canvas URL
tohttps://localhost/
and app domain tolocalhost
- In Facebook Login Products setting also I checked Valid OAuth redirect URIs
to
https://localhost/
- FB API version 2.10
Still not firing and users not logged off when they remove my app.
If I refresh main.php
its working and users get logged off.
I saw the following similar questions/answer but none of them solve my issue.
why facebook FB.Event.subscribe is not working?
how to detect log out from fb using JS SDK without refreshing the page
FB JS-SDK cannot detect user logging out of FB directly
How to detect user logging out of Facebook after logging into my app?
I wonder whats wrong.
Thank you
Update: the event is fired but after waiting like an hour; so most likely its some caching issue! Can't be sure.
Update2:
Trying to figure out whats wrong! I had tried the following:
- Downgrade
jQuery
from version 3 to version 2 - Load my app from Live Server and not
localhost
- Check
app settings
- Check
console.log
for everything; but no error is returned! with All Levels enabled; I am getting only[Violation] 'message' handler took 2450ms
- Checked Facebook Platform and it is
Healthy
- Loaded Facebook SDK into
<head>
(sdk.js
) - Tried different browsers Chrome Latest, FF Latest and Edge Latest and Mobile same result. Only Edge return :
The code on this page disabled back and forward caching.
Which I think irrelevant. - Also tried to use FB API V 2.8
Still no joy
Here is my app settings:
That's so funny! Please advice!
Thank you