Reputation: 46
I am making an HTML5 app using cocoonjs, when trying to login into facebook as i click the login button it opens the facebook app or facebook website on safari, after this if i close the facebook app/safari then my app doesnt get notified of this kind of login failure
how do I detect this?
this is my code
if (this.socialService && !this.socialService.isLoggedIn()) {
this.socialService.login(function(session) {
self.log(session);
if (session.status !== "connected") {
console.log("not connected");
}
}, { scope: "publicprofile,user_friends" });
} else {
console.log("not connected");
}
Upvotes: 0
Views: 78
Reputation: 2553
The documentation for the Facebook js sdk has an example:
FB.login(function(response) {
if (response.status === 'connected') {
// Logged into your app and Facebook.
} else if (response.status === 'not_authorized') {
// The person is logged into Facebook, but not your app.
} else {
// The person is not logged into Facebook, so we're not sure if
// they are logged into this app or not.
}
});
Check the session.status
of your code to check the conditions as shown in the example. If status is anything other than connected
or not_authorized
it could mean that the Facebook app/safari was closed.
Upvotes: 0