Social Login (for ionic 4 app)
Read this document to avoid any mistake or conflict - https://github.com/EddyVerbruggen/cordova-plugin-googleplus
Uncommenting the code
//import { Facebook } from '@ionic-native/facebook/ngx';
//import { GooglePlus } from '@ionic-native/google-plus/ngx';// Facebook,
// GooglePlus,/*private googlePlus: GooglePlus, private fb: Facebook*//*googleLogin(){
this.googleLogingInn = true;
this.googlePlus.login({})
.then(res => {
this.googleStatus = res;
this.api.postItem('google_login', {
"access_token": this.googleStatus.userId,
"email": this.googleStatus.email,
"first_name": this.googleStatus.givenName,
"last_name": this.googleStatus.familyName,
"display_name": this.googleStatus.displayName,
"image": this.googleStatus.imageUrl
}).subscribe(res => {
this.status = res;
if (this.status.errors) {
this.errors = this.status.errors;
} else if (this.status.data) {
this.settings.customer.id = this.status.ID;
if (this.platform.is('cordova')){
this.oneSignal.getIds().then((data: any) => {
this.form.onesignal_user_id = data.userId;
this.form.onesignal_push_token = data.pushToken;
});
this.api.postItem('update_user_notification', this.form).subscribe(res =>{});
}
if(this.status.allcaps.dc_vendor || this.status.allcaps.seller || this.status.allcaps.wcfm_vendor){
this.settings.vendor = true;
}
this.navCtrl.navigateBack('/tabs/account');
}
this.googleLogingInn = false;
}, err => {
this.googleLogingInn = false;
});
this.googleLogingInn = false;
})
.catch(err => {
this.googleStatus = err;
this.googleLogingInn = false;
});
}
facebookLogin(){
this.facebookLogingInn = true;
this.facebook.login(['public_profile', 'user_friends', 'email'])
.then((res: FacebookLoginResponse) => {
this.googleStatus = res;
this.api.postItem('facebook_login', {
"access_token": this.googleStatus.userId,
}).subscribe(res => {
this.status = res;
if (this.status.errors) {
this.errors = this.status.errors;
} else if (this.status.data) {
this.settings.customer.id = this.status.ID;
if (this.platform.is('cordova')){
this.oneSignal.getIds().then((data: any) => {
this.form.onesignal_user_id = data.userId;
this.form.onesignal_push_token = data.pushToken;
});
this.api.postItem('update_user_notification', this.form).subscribe(res =>{});
}
if(this.status.allcaps.dc_vendor || this.status.allcaps.seller || this.status.allcaps.wcfm_vendor){
this.settings.vendor = true;
}
this.navCtrl.navigateBack('/tabs/account');
}
this.facebookLogingInn = false;
}, err => {
this.facebookLogingInn = false;
});
this.facebookLogingInn = false;
})
.catch(e => {
this.googleStatus = e;
this.facebookLogingInn = false;
});
}*/Google Authentication
Facebook Authentication


Last updated