我正在使用cocoonjs制作HTML5应用程序,当我尝试登录Facebook时,当我单击登录按钮时,它会在Safari上打开Facebook应用程序或Facebook网站,之后如果我关闭Facebook App/Safari,那么我的应用程序不会收到这种登录失败的通知
如何检测?
这是我的代码
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");
}
Facebook js sdk 的文档有一个示例:
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.
}
});
检查代码的session.status
以检查条件,如示例中所示。如果状态不是connected
或not_authorized
则可能意味着Facebook应用程序/野生动物园已关闭。