我在用着:
– 离子
– ngCordova
– http://ngcordova.com/docs/plugins/facebook/
这是我的代码:
angular.module('starter.controllers',['ngCordova']) .config(function($cordovaFacebookProvider) { var appID = 123456789; var version = "v2.0"; // or leave blank and default is v2.0 $cordovaFacebookProvider.browserInit(appID,version); })
这导致了这个错误>
Uncaught Error: [$injector:modulerr] Failed to instantiate module starter due to: Error: [$injector:modulerr] Failed to instantiate module starter.controllers due to: ReferenceError: facebookConnectPlugin is not defined at browserInit (http://localhost:8100/lib/ngCordova/dist/ng-cordova.js:1576:7) at http://localhost:8100/js/controllers.js:6:30 at Object.invoke (http://localhost:8100/lib/ionic/js/ionic.bundle.js:11994:17) at runInvokeQueue (http://localhost:8100/lib/ionic/js/ionic.bundle.js:11900:35) at http://localhost:8100/lib/ionic/js/ionic.bundle.js:11909:11 at forEach (http://localhost:8100/lib/ionic/js/ionic.bundle.js:8147:20) at loadModules (http://localhost:8100/lib/ionic/js/ionic.bundle.js:11890:5) at http://localhost:8100/lib/ionic/js/ionic.bundle.js:11907:40 at forEach (http://localhost:8100/lib/ionic/js/ionic.bundle.js:8147:20) at loadModules (http://localhost:8100/lib/ionic/js/ionic.bundle.js:11890:5)
尝试了一些事情,但没有任何积极的结果:
– 当我构建它并运行在我的设备上时,该应用程序显示一个空白屏幕
试过正常的cordova js代码:
>更改$cordovaFacebookProvider到$cordovaFacebook(基于此线程:
forum.ionicframework.com/t/unknown-provider-cordovaprovider/13305/3
>这是另一个相关的线程,但不帮我想
forum.ionicframework.com/t/does-ng-crodova-has-facebook-login/9163
我已经有一个在应用程序内浏览器中使用fb auth的原型.但是我真的想要一个本地的fb连接功能.
感谢这个线程:https://github.com/driftyco/ng-cordova/issues/446
和本教程:https://github.com/Wizcorp/phonegap-facebook-plugin/blob/master/platforms/browser/README.md
第一步:不要忘记< div id =“fb-root”>< / div>后身体.
第二步:我添加了facebookConnectPlugin到我的凉亭依赖
看我的bower.json:
"dependencies": { "angular-google-maps": "~2.0.13","google-map": "~0.4.1","facebook-connect-plugin": "https://cdn.rawgit.com/Wizcorp/phonegap-facebook-plugin/master/facebookConnectPlugin.js" }
看到我的app.config代码到init:
app.config(function ($stateProvider,$urlRouterProvider,$ionicConfigProvider,$animateProvider,$httpProvider,$cordovaFacebookProvider) { var appID = 597135743751760; var version = "v2.0"; // or leave blank and default is v2.0 $cordovaFacebookProvider.browserInit(appID,version);
$cordovaFacebookProvider调用facebookConnectPlugin()
第3步:改变这个依赖关系后,别忘了从ur CLI中调用bower update.
第四步:在您的index.html中加入新的facebookblablabla.js.
有可能
<script src='bower_components/facebook-connect-plugin/index.js'></script>
对我而言
<script src='lib/facebook-connect-plugin/index.js'></script>
第五步:在您的Facebook应用程序中添加有效的OAuth重定向URI字段:
http://static.ak.facebook.com/connect/xd_arbiter/
希望对你有帮助 :) !