如何在离子中使用phonegap-facebook-plugin?

时间:2015-04-23 16:21:00

标签: android cordova ionic ngcordova

我正在ionic / Cordova中构建应用,我希望我的用户能够使用Facebook登录。因此,我尝试安装PhonegapFacebookPlugin上找到的ngCordova.com

我注意到的第一件事是,在Android上安装插件的docs on the ngCordova.com websitethe project's github docs上的文档不同。所以我首先尝试在github页面上使用(更简单的)指令,在安装并尝试使用以下代码之后:

facebookConnectPlugin.login(['email'],
    function(data){ console.log(JSON.stringify(data));},
    function(error){console.log(error);});

导致了这些错误:

file:///android_asset/www/lib/phonegap-facebook-plugin-master/facebookConnectPlugin.js: Line 181 : Uncaught ReferenceError: require is not defined
file:///android_asset/www/js/app.js: Line 23 : Uncaught TypeError: Cannot read property 'Keyboard' of undefined
file:///android_asset/www/lib/ionic/js/ionic.bundle.js: Line 19387 : TypeError: Cannot call method 'login' of undefined
    at Scope.$scope.fbLogin (file:///android_asset/www/js/controllers.js:10:31)
    at $parseFunctionCall (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:20124:18)
    at file:///android_asset/www/lib/ionic/js/ionic.bundle.js:50863:9
    at Scope.$eval (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:22178:28)
    at Scope.$apply (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:22276:23)
    at HTMLButtonElement.<anonymous> (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:50862:13)
    at HTMLButtonElement.eventHandler (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:10823:21)
    at triggerMouseEvent (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:2811:7)
    at tapClick (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:2800:3)
    at HTMLDocument.tapTouchEnd (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:2918:5)

在遇到这些错误后,我尝试继续使用更广泛的installation instructions on the ngCordova website,但是以下命令:

android update project --subprojects --path "platforms/android" --target android-19 --library "com.phonegap.plugins.facebookconnect/FacebookLib"

导致以下错误:

Resolved location of library project to: /Users/kramer65/repos/my-app/platforms/android/com.phonegap.plugins.facebookconnect/FacebookLib
Error: Project folder '/Users/kramer65/repos/my-app/platforms/android/com.phonegap.plugins.facebookconnect/FacebookLib' is not a valid directory.
Error: No Android Manifest at: /Users/kramer65/repos/my-app/platforms/android/com.phonegap.plugins.facebookconnect/FacebookLib

这是有道理的,因为com.phonegap.plugins.facebookconnect/文件夹中没有名为platforms/android/的文件夹。我不知道为什么不这样做。我需要在那里复制粘贴吗?或者在上一步中出了什么问题?

我被困在这里,我真的需要让这个工作。任何帮助将不胜感激!

0 个答案:

没有答案