Titanium facebook模块单线程

时间:2013-10-08 22:55:17

标签: facebook titanium titanium-modules titanium-alloy

我使用Titanium(3.1.3)和Alloy实现了facebook登录。

但有时候当我尝试登录时,我会发现此消息错误。

message = "FBSession: should only be used from a single thread";

2 个答案:

答案 0 :(得分:1)

在SocialIntegrations调用中,您必须在授权后使用您的Facebook令牌

Alloy.Globals.Facebook = require('facebook');

    Alloy.Globals.Facebook.addEventListener('login', function(e) {
    if (e.success) {
        alert('Logged In' + JSON.stringify(e));
        Cloud.SocialIntegrations.externalAccountLogin({
            type : 'facebook',
            token : Alloy.Globals.Facebook.accessToken
        }, function(e) {
            if (e.success) {
                var user = e.users[0];
               // success
            } else {
                //error
            }
        });
    } else if (e.error) {
        alert(e.error);
    } else if (e.cancelled) {
        alert("Canceled");
    }
});

答案 1 :(得分:0)

如果您要发布用于Facebook集成的代码,那么回答会更容易。

你可能在fb.authorize()之后调用了一些fb方法。将对Facebook进行的所有查询移至事件监听器:

fb.addEventListener('login', function(event) {
  if (e.success) {
    /* your code */
  }
});

同时从Appcelerator论坛查看这些资源: