Ionic Firebase social login help
-
ෆර්බේස් සොශල් ලොගින් ඇන්ඩ්රොයිඩ් ඩිවයිස් එකෙ හරියට වැඩකරන විදියට හදාගන්න විදිය ගැන කියලා දෙන්න පුලුවන්ද? විදි කීපයක් ට්රයි කරා සාර්තක උනේ නැහැ.
-
@oditha mona social login ekata integrate karanna one?
-
Facebook& Google. Firebase haraha karala thiyenne. Eka web browser eke test karanakota wada karanawa. But build karala android devices ekata damama wada karanne naha.
-
@oditha android device eke wada karannanm, sign key eke SHA signature eka add krnna one google developer console ekata, facebook ekatath key ekak add krnna one
-
@dev_lak me dekama karala thiyenne. prahsne app eken login dunnama native popup eka wenuwata web browser eka open wenawa.
-
@oditha ahh native popup eka ganna me widiyata try karala blnna
let params = {}; if (this.platform.is('android')) { params = { webClientId: '', // webclientID 'string' offline: true }; } return this.google.login(params);
-
@dev_lak thanks bro! man try karla balala update ekak dennam
-
@dev_lak auth service eke code eka
signInWithFacebook() { const provider = new firebase.auth.FacebookAuthProvider(); // const scopes = ['user_birthday']; return this.socialSignIn(provider.providerId); } signInWithGoogle() { const provider = new firebase.auth.GoogleAuthProvider(); const scopes = ['profile', 'email']; return this.socialSignIn(provider.providerId, scopes); } socialSignIn(providerName: string, scopes?: Array<string>): Promise<any> { const provider = new firebase.auth.OAuthProvider(providerName); // add any permission scope you need if (scopes) { scopes.forEach(scope => { provider.addScope(scope); }); } if (this.platform.is('desktop')) { return this.afAuth.signInWithPopup(provider); } else { // web but not desktop, for example mobile PWA return this.afAuth.signInWithRedirect(provider); } }
Me page eke code eaka.
facebookSignIn() { this.authService.signInWithFacebook() .then((result: any) => { if (result.additionalUserInfo) { this.authService.setProviderAdditionalInfo(result.additionalUserInfo.profile); } // This gives you a Facebook Access Token. You can use it to access the Facebook API. // const token = result.credential.accessToken; // The signed-in user info is in result.user; this.tabs(); }).catch((error) => { // Handle Errors here. console.log(error); }); } googleSignIn() { this.authService.signInWithGoogle() .then((result: any) => { if (result.additionalUserInfo) { this.authService.setProviderAdditionalInfo(result.additionalUserInfo.profile); } // This gives you a Google Access Token. You can use it to access the Google API. // const token = result.credential.accessToken; // The signed-in user info is in result.user; this.tabs(); }).catch((error) => { // Handle Errors here. console.log(error); }); }
uda answer eka mata clear madi. mekata galpenna kiyanna puluwanda?
-
@oditha me code eka balann terenwada kyla, platform and android hari ios hrinm me widiyt krnna, Google plus plugin eka use krnna native popup eka ganna
Auth Service
import { GooglePlus } from '@ionic-native/google-plus/ngx'; import { Platform } from '@ionic/angular'; import { AngularFireAuth } from "@angular/fire/auth"; constructor( public ngFireAuth: AngularFireAuth, private google: GooglePlus, private platform: Platform, ) { } // Google Login googleLogin() { let params = {}; if (this.platform.is('android')) { params = { webClientId: '', // put webclientID 'string' offline: true }; } return this.google.login(params); } // Callback method for Google Login onGoogleLoginSuccess(accessToken, accessSecret) { const credential = accessSecret ? auth.auth.GoogleAuthProvider.credential(accessToken, accessSecret) : auth.auth.GoogleAuthProvider.credential(accessToken); return this.ngFireAuth.signInWithCredential(credential); }
Login Page
import { AuthService } from '../../services/auth.service'; constructor( private auth: AuthService, ) {} googleLogin() { this.auth.googleLogin() .then(response => { const { idToken, accessToken } = response; this.auth.onGoogleLoginSuccess(idToken, accessToken) .then(user => { console.log(user.user); }) .catch(err => { console.log(err) }); }
-
@dev_lak meka nam balala karaganna puluwan wei wage. ethakota facebook signin eke popup eka ganna widiyak thiyeda?
-
@oditha oka balal kynna bro, wadanm fb code ekath dannam, Ionic version eka mkkda use krna?
-
@dev_lak Thanx bro. Ionic 5
-
@oditha wade hari giyada?
-
@dev_lak Thwama Naha bro.
Me line eke
const credential = accessSecret ? auth.auth.GoogleAuthProvider.credential(accessToken, accessSecret) : auth.auth.GoogleAuthProvider.credential(accessToken);
auth.auth not found error Eka throw wenwa.
Web Client Id eka kohomda ganne?
-
a machna auth eka
import auth from 'firebase/app';
meken enne -
@oditha web client id eka firebase eke google login ekt gyama penwnwa
-
@dev_lak Me dekma hri. mama meka try karala feedback ekak dennam. again thank you very much for the help.
-
@oditha elama
-
@dev_lak mekedi android source eka patten karanna monwa hri thiyenwada? meka dala test karama splash screen eke nawatila thiyenwa
-
Me kotasa add karagen passe ionic serve run karama blank black page ekak enne browser eket