【问题标题】:how to make ionic 3 redirect to app after login using google account?使用谷歌帐户登录后如何使 ionic 3 重定向到应用程序?
【发布时间】:2024-01-02 06:46:01
【问题描述】:

我想问我应该怎么做才能让我的 ionic 3 应用程序在使用谷歌帐户登录时返回应用程序。

我已经配置它并且它正在成功登录,但网络视图被重定向到 google.com 主页,而不是像往常一样返回到应用程序

这是我的代码:

this.googlePlus.login({}).then(result => {
  console.error("LoginWithGooglePlus success: ", JSON.stringify(result));
  console.log("Google userId: ", result.userId);
  console.log("Google displayName: ", result.displayName);
  console.log("Google email: ", result.email);
  console.log("Google givenName: ", result.givenName);
  console.log("Google familyName: ", result.familyName);
  this.navCtrl.setRoot(HomePage, {}, { animate: true, animation: 'ios-transition' });
}).catch(error => {
  console.error("LoginWithGooglePlus error: ", JSON.stringify(error));
});

我想提一下,我之前在另一个应用程序上使用过这段代码,它运行良好,但现在什么都没有发生,它是登录并直接重定向到 google plus 而不返回应用程序!

等待帮助,谢谢

【问题讨论】:

  • 嗨,请分享一些代码以获得帮助;)

标签: ionic-framework ionic3 google-plus google-signin


【解决方案1】:

请试试这个

import {AlertController, App, ViewController, Events, NavController, LoadingController, Platform} from 'ionic-angular';

constructor(public http: Http,
                public app: App,
                public platform: Platform,
                public loadingCtrl: LoadingController,) {
        console.log('Hello Google Service Provider');
    }

this.app.getRootNav().setRoot('HomePage');

【讨论】:

    【解决方案2】:

    我也遇到过,找到了解决办法 https://*.com/a/56569302/7469439

    希望这对某人有所帮助

    【讨论】: