我对移动应用程序开发和离子2很陌生。我让谷歌认证在使用angularfire2的网络应用程序上运行得很好,但在移动设备上不起作用(还没有?)我使用的是离子2版本2.0.0-beta.35和firebase 3.2.1
搜索使我了解到,目前我需要为cordova使用google+插件,我已经安装了该插件。
我正在我的ts代码中尝试这个方法:
loginWithGooglePlugin()
{
return Observable.create(observer =>
{
// note for iOS the googleplus plugin requires ENABLE_BITCODE to be turned off in the Xcode
window.plugins.googleplus.login(
{
'scopes': 'profile email', // optional, space-separated list of scopes, If not included or empty, defaults to `profile` and `email`.
'webClientId': '_google_client_app_id_.apps.googleusercontent.com',
'offline': true, // optional, but requires the webClientId - if set to true the plugin will also return a serverAuthCode, which can be used to grant offline access to a non-Google server
},
function (authData)
{
console.log('got google auth data:', JSON.stringify(authData, null, 2));
let provider = firebase.auth.GoogleAuthProvider.credential(authData.idToken, authData.accessToken);
firebase.auth().signInWithCredential(provider).then((success) =>
{
console.log('success!', JSON.stringify(success, null, 2));
observer.next(success);
}, (error) =>
{
console.log('error', JSON.stringify(error, null, 2))
});
},
function (msg)
{
this.error = msg;
}
);
});
}但是编译器总是抱怨两件事: 1. window.plugins是未知的。我怎么能让泰斯相信它就在那里?
credential对象上没有GoogleAuthProvider。搜索产生了这样的链接:[消]火源文档,它说有一个方法getCredential,这个方法也不被识别。我的typings似乎很好。GoogleAuthProvider本身是被识别的。
我怎么才能解决这个问题?
发布于 2016-08-04 21:03:21
实际上,这是类型记录定义中的一个错误。Firebase团队已经收到通知,正在进行修复。同时,请使用以下解决方法:
(<any> firebase.auth.GoogleAuthProvider).credential 发布于 2016-11-12 23:34:50
在我的Ionic2 RC1 + Firebase3.5 3.5+ AngularFire2.beta5项目中,我遇到了同样的问题.Google的弹出窗口在浏览器中工作,但在我的Android .APK中没有工作。
首先,我将192.168.1.172添加到我的Firebase控制台授权域列表中,将<allow-navigation href="http://192.168.1.172:8100"/>添加到我的config.xml中。
在此之后,我发现安装Cordova InAppBrowser插件彻底解决了我的问题。
我不需要修改我的代码,只需要即插即用,就像David在他的用Ionic博客登陆社交网站中所说的。
https://stackoverflow.com/questions/38735845
复制相似问题