我正在使用appcelerator的facebook模块5.0.1及其5.2.1ga sdk。我无法让模块显示Facebook登录对话框进行共享。这是我的代码:
var FacebookPublic = require("FacebookPublic");
var fb = require('facebook');
// Test
// fb.setLoginBehavior(fb.LOGIN_BEHAVIOR_WEB );
// fb.permissions = ['email'];
// fb.permissions = ['read_stream','publish_actions'];
// fb.initialize();
fb.authorize();
if ( fb.getLoggedIn() == false )
{
alert('Error Logging Into Facebook');
return;
}
我的代码不记录任何错误,只是通过fb.authorize()向警报('Error Logging Into Facebook')声明。我尝试了各种登录行为(请参阅我的代码中的注释部分)
这是我的tiapp.xml中的plist
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fbXXX</string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string>XXX</string>
<key>FacebookDisplayName</key>
<string>MYFACEBOOKAPP</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
<string>fbapi20130214</string>
<string>fbapi20130410</string>
<string>fbapi20130702</string>
<string>fbapi20131010</string>
<string>fbapi20131219</string>
<string>fbapi20140410</string>
<string>fbapi20140116</string>
<string>fbapi20150313</string>
<string>fbapi20150629</string>
<string>fbauth</string>
<string>fb-messenger-api20140430</string>
</array>
我已使用我的bundleId为IOS配置了我的脸书开发人员帐户。相同的代码在我的Android应用程序中没有问题。有没有人对如何使这个工作有任何想法?
由于
答案 0 :(得分:0)
var fb = require('facebook');
fb.permissions = [FACEBOOK_APP_PERMISSIONS];
fb.initialize(); // <-- YOU NEED INITIALIZE MODULE
//for get error or success add listener
fb.addEventListener('login', function(e) {
if (e.success) {
alert('login from uid: '+e.uid+', name: '+ JSON.parse(e.data).name);
label.text = 'Logged In = ' + fb.loggedIn;
}
else if (e.cancelled) {
// user cancelled
alert('cancelled');
}
else {
alert(e.error);
}
});
fb.authorize();