2013-10-08 87 views
5

我實現了與鈦(3.1.3)和合金的facebook登錄。鈦facebook模塊單線程

但是有時我錯過了這條消息當我嘗試登錄時出現錯誤。

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

回答

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"); 
    } 
}); 
+0

請解釋。 – CyberJunkie

0

這將是比較容易回答,如果你將發佈你使用Facebook的整合代碼。

你可能在fb.authorize()後面調用了一些fb方法。移動至Facebook的所有查詢到事件偵聽器:

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

而且從Appcelerator的論壇看看這些資源:

+0

我試試這個,但不工作 – jay

+0

請在產生此錯誤代碼。 你檢查了我在下面添加的鏈接嗎? – daniula