0

我正在使用 cocoonjs 制作一个 HTML5 应用程序,当我单击登录按钮时尝试登录 facebook 时,它会在 safari 上打开 facebook 应用程序或 facebook 网站,之后如果我关闭 facebook 应用程序/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"); }

4

1 回答 1

0

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 应用程序/Safari 已关闭。

于 2015-04-25T22:37:47.623 回答