问题
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