简体   繁体   English

Ionic View Google登录弹出窗口在Firebase 2中有效,但在Firebase 3中无效(在浏览器中有效)

[英]Ionic View Google Login Popup works in Firebase 2, but not in Firebase 3 (works in browser)

I am trying to implement Google authentication in my ionic app. 我正在尝试在离子应用程序中实现Google身份验证。 I found this sample app on GitHub ( click here ) which uses Google to login. 我在使用Google登录的GitHub( 单击此处 )上找到了此示例应用程序。

  • When I serve it to the browser (using ionic serve --lab), the popup works. 当我将其提供给浏览器(使用ionic serve --lab)时,弹出窗口将起作用。 I am able to login in and access the data. 我可以登录并访问数据。
  • When I upload it to ionic and open the app on iOS/Android emulator, it works. 当我将其上传到ionic并在iOS / Android仿真器上打开应用程序时,它可以工作。
  • When I build it and emulate it on android, the popup does not work. 当我构建它并在android上模拟它时,弹出窗口不起作用。

I tried to upgrade the app using Firebase's Migration guide ( click here ), but I was only able to get it working in the browser, not in ionic view or android emulator. 我尝试使用Firebase的《迁移指南》( 单击此处 )升级该应用程序,但是我只能使其在浏览器中运行,而不能在ionic view或android emulator中运行。

I also added Google sign in to a separate app, but I was only able to get it working in the browser. 我也将Google登录添加到单独的应用中,但是我只能在浏览器中使用它。

var provider = new firebase.auth.GoogleAuthProvider();
firebase.auth().signInWithPopup(provider).then(function (response) {
  // Login successful
}, function(error) {
  // Login error
});

Any help will be great! 任何帮助都会很棒!

A side question, am I still able to use Firebase 2.xx even though I am using the new Firebase console? 附带的问题是,即使我使用新的Firebase控制台,我仍然可以使用Firebase 2.xx吗? I think firebase did give me an error once saying I was using new Firebase console so needed to use the latest libraries or something. 我认为Firebase曾经说我正在使用新的Firebase控制台,所以确实给了我一个错误,因此需要使用最新的库或其他内容。

Firebase auth 3.x for Ionic/Cordova on android and iOS currently does not support signInWithPopup. 适用于Android和iOS上的Ionic / Cordova的Firebase auth 3.x当前不支持signInWithPopup。 The Firebase team is working on supporting that. Firebase团队正在为此提供支持。 Check this thread for more on how to handle this situation: https://groups.google.com/forum/#!searchin/firebase-talk/cordova $20facebook/firebase-talk/mC_MlLNCWnI/DqN_8AuCBQAJ 检查此线程以了解有关如何处理这种情况的更多信息: https ://groups.google.com/forum/#!searchin/firebase-talk/cordova $ 20facebook / firebase-talk / mC_MlLNCWnI / DqN_8AuCBQAJ

For now, you can use signInWithCredential as an alternative. 目前,您可以使用signInWithCredential作为替代。 There are cordova plugins for Google and Facebook which would help provide you with an OAuth access token that you can use to call signInWithCredential: 有适用于Google和Facebook的cordova插件,可帮助您提供OAuth访问令牌,可用于调用signInWithCredential:

auth.signInWithCredential(firebase.auth.FacebookAuthProvider.credential(fbAccessToken));

One example of a plugin for facebook sign in: https://www.npmjs.com/package/cordova-plugin-facebook Facebook登录插件的一个示例: https : //www.npmjs.com/package/cordova-plugin-facebook

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM