Display google login data in other page ionic

拥有回忆 提交于 2019-12-24 21:19:11

问题


i'm trying to add google login to my apps, i use firebase. Login button and function is on welcome page like this.

logic.service.ts

 login(){
this.googlePlus.login({
  'webClientId' : 'webapi.apps.googleusercontent.com',
  'offile' : true
}).then(res=>{
  firebase.auth().signInWithCredential(firebase.auth.GoogleAuthProvider.credential(res.idToken))
  .then(suc=>{
    this.router.navigate(["/tabs/home"]);
    this.user = res;
    this.getData();
    console.log(this.user);
  }).catch(ns=>{
    alert('Unsucessful');
  })
})

} and when user login, they redirected to home.page.html. But i need that google login data such as email name image on my profile page. How can i achieve that?

home.page.ts

subscribe: any;
  users:any={};
  public items: any;
  constructor(
    private iab: InAppBrowser,
    private router: Router,
    public platform: Platform,
    private service: LogicService
    ) {

    this.subscribe = this.platform.backButton.subscribeWithPriority(666666, () => {
      if (this.constructor.name === 'HomePage') {
        if (window.confirm('Do you want to exit the app?')) {
          (navigator as any).app.exitApp();
        }
      }
    });
  }
  go() {
      this.router.navigateByUrl('tabs/login');
  }

  ngOnInit(){
    let user = JSON.parse(localStorage.getItem(this.users));
    this.service.getLocalData().subscribe(
      data => {this.items = data});
  }
  webview(url){
    this.iab.create(url, '_self', 'location=no,toolbar=no,zoom=no');
  }

i try to call user name and images on profile.page.ts like this

<ion-col class="photo_wrap" size="12">
        <img class="photo_profile" src="{{ users.image }}" alt="">
        <p class="name">{{ users.name }}</p>
        <p style="color:lightgrey;" class="name">{{ users.user_uid }}</p>
      </ion-col>

am i wrong? because when i install it, i can't access profile page

来源:https://stackoverflow.com/questions/59233977/display-google-login-data-in-other-page-ionic

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!