Ionic Firebase Google登录不起作用,控制台上没有错误

时间:2019-03-13 05:42:17

标签: firebase cordova ionic-framework

我正在将Google登录信息与Firebase集成在一起。 我在Firebase端完成了所有必需的设置。也为此做了一个试点项目,效果很好。 Google登录成功。然后,同样的东西我正在与我的项目购物车集成在一起,然后就无法正常工作了。相同代码在控制台上没有错误。不知道出了什么问题。所有package.json版本都是相同的,只是增加了一些依赖。

尝试以下代码:

if (this.platform.is('cordova')) {
  // here is coming but not going in then
  this.googlePlus.login({
    'scopes': '', // optional, space-separated list of scopes, If not included or empty, defaults to `profile` and `email`.
    'webClientId': environment.googleWebClientId, // optional clientId of your Web application from Credentials settings of your project - On Android, this MUST be included to get an idToken. On iOS, it is not required.
    'offline': true
  }).then((response) => {
    // Here firebase login
    const googleCredential = firebase.auth.GoogleAuthProvider.credential(response.idToken);
    firebase.auth().signInWithCredential(googleCredential)
      .then(user => {
        console.log("Firebase success: " + JSON.stringify(user));
        resolve();
      });
  }, (err) => {
    console.log("Error in doGoogleLogin " + err);
    reject(err);
  });
}

没有出现任何错误部分

1 个答案:

答案 0 :(得分:0)

最后,经过将近1个月的苦苦挣扎,我终于明白了。 在我的plugin文件夹中,实验时安装了许多插件,这解决了这个问题。 所以我所做的是删除了plugin文件夹,并运行以下命令以获取解决方法

//删除平台

  

ionic cordova平台rm android --save

//添加平台

  

ionic cordova平台添加android@6.4.0 --save

//构建离子

  

ionic cordova构建android