将 google plus 登录添加到 ionic 应用程序 [英] Adding google plus login to ionic app
本文介绍了将 google plus 登录添加到 ionic 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将 google plus 登录添加到我的 ionic 应用
.按照这个链接给我一个错误.
I am trying to add google plus login to my ionic app
.
Following this link gives me an error.
https://ionicthemes.com/tutorials/about/google-plus-login-with-ionic-framework
错误是:无法读取未定义的属性googleplus.
这是我的 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) 中配置身份验证的步骤
Steps to Configure authentication in Device(android)
ionic start newApp
ionic 平台添加安卓
cordova 插件添加cordova-plugin-inappbrowser
bower 安装 ngCordova
bower install ng-cordova-oauth -S
将两个脚本都包含到
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>
依赖注入
Dependency injection
包含以下代码
$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);
});
}
添加按钮查看文件和调用函数
add button to view file and call the function
这篇关于将 google plus 登录添加到 ionic 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文