我正在尝试在页面加载事件后检查用户是否已经与我的FB应用程序连接。为此,我调用了FB.getLoginStatus函数。它适用于所有地方,但iOS下的Safari(在iPhone5,iPhone6和iPad Air上测试)。
有谁知道它为什么会这样? :)
这是我的代码:
bla.facebook = (function (me) {
me.logged = function (params) {
FB.getLoginStatus(function (response) {
console.log('FB.getLoginStatus done');
if (response.status === 'connected') {
if (typeof params.success === 'function') {
params.success(response);
}
} else {
if (typeof params.failure === 'function') {
params.failure(response);
}
}
});
};
me.login = function (params) {
FB.login(function (response) {
console.log('FB.login done');
if (response.authResponse) {
if (typeof params.success === 'function') {
params.success(response);
}
} else {
if (typeof params.failure === 'function') {
params.failure(response);
}
}
});
};
return me;
}(bla.facebook || {}));
// ON PAGE LOAD I CALL THAT
// CALLBACKS ARE NOT CALLED AT ALL
// NO FB.getLoginStatus done IN CONSOLE OUTPUT
bla.facebook.logged({
success: function (response) {
console.log('user is logged');
},
failure: function (response) {
console.log('user is not logged');
}
});
// THAN ON BUTTON CLICK I CALL THAT
// AND EVERYTHING WOKRS JUST PERFECT
bla.facebook.login({
success: function (response) {
console.log('login success');
},
failure: function (response) {
console.log('login failure');
}
});
答案 0 :(得分:-1)
您需要将Facebook更新为V2.5