我正在尝试将google plus登录名添加到我的ionic app。跟随此链接给我一个错误。
ionic app
https://ionicthemes.com/tutorials/about/google-plus-login-with-ionic- framework
错误是: cannot read property googleplus of undefined.
cannot read property googleplus of undefined.
这是我的app.js:
app.js
.run(function($ionicPlatform) { $ionicPlatform.ready(function() { if (window.cordova && window.cordova.plugins.Keyboard) { cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true); cordova.plugins.Keyboard.disableScroll(true); } if (window.StatusBar) { // org.apache.cordova.statusbar required StatusBar.styleDefault(); } }); })
在Device(android)中配置身份验证的步骤
ionic start newApp
ionic platform add android
cordova plugin add cordova-plugin-inappbrowser
bower install ngCordova
bower install ng-cordova-oauth -S
index.html
cordova.js
<script src="lib/ngCordova/dist/ng-cordova.min.js"></script> <script src="lib/ng-cordova-oauth/dist/ng-cordova-oauth.js"></script> <script src="cordova.js"></script>
依赖注入
包含以下代码
$scope.googleLogin = function() { console.log('In My Method'); $cordovaOauth.google("Client ID", ["https://www.googleapis.com/auth/urlshortener", "https://www.googleapis.com/auth/userinfo.email"]).then(function(result) { console.log(JSON.stringify(result)); // results }, function(error) { // error console.log('In Error'); console.log(error); }); }