Lanka Developers Community

    Lanka Developers

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Shop

    Ionic Firebase social login help

    Hybrid App Development
    ionic firebase
    2
    31
    2616
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • oditha
      oditha Web Development last edited by

      ෆර්බේස් සොශල් ලොගින් ඇන්ඩ්‍රොයිඩ් ඩිවයිස් එකෙ හරියට වැඩකරන විදියට හදාගන්න විදිය ගැන කියලා දෙන්න පුලුවන්ද? විදි කීපයක් ට්‍රයි කරා සාර්තක උනේ නැහැ.

      dev_lak 1 Reply Last reply Reply Quote 0
      • dev_lak
        dev_lak @oditha last edited by

        @oditha mona social login ekata integrate karanna one?

        oditha 1 Reply Last reply Reply Quote 0
        • oditha
          oditha Web Development @dev_lak last edited by

          Facebook& Google. Firebase haraha karala thiyenne. Eka web browser eke test karanakota wada karanawa. But build karala android devices ekata damama wada karanne naha.

          dev_lak 1 Reply Last reply Reply Quote 1
          • dev_lak
            dev_lak @oditha last edited by

            @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

            oditha 1 Reply Last reply Reply Quote 0
            • oditha
              oditha Web Development @dev_lak last edited by

              @dev_lak me dekama karala thiyenne. prahsne app eken login dunnama native popup eka wenuwata web browser eka open wenawa.

              dev_lak 1 Reply Last reply Reply Quote 0
              • dev_lak
                dev_lak @oditha last edited by dev_lak

                @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);
                
                oditha 2 Replies Last reply Reply Quote 0
                • oditha
                  oditha Web Development @dev_lak last edited by

                  @dev_lak thanks bro! man try karla balala update ekak dennam

                  1 Reply Last reply Reply Quote 0
                  • oditha
                    oditha Web Development @dev_lak last edited by

                    @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?

                    dev_lak 1 Reply Last reply Reply Quote 0
                    • dev_lak
                      dev_lak @oditha last edited by

                      @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) });
                      }
                      
                      oditha 1 Reply Last reply Reply Quote 0
                      • oditha
                        oditha Web Development @dev_lak last edited by

                        @dev_lak meka nam balala karaganna puluwan wei wage. ethakota facebook signin eke popup eka ganna widiyak thiyeda?

                        dev_lak 1 Reply Last reply Reply Quote 0
                        • dev_lak
                          dev_lak @oditha last edited by

                          @oditha oka balal kynna bro, wadanm fb code ekath dannam, Ionic version eka mkkda use krna?

                          oditha 2 Replies Last reply Reply Quote 0
                          • oditha
                            oditha Web Development @dev_lak last edited by

                            @dev_lak Thanx bro. Ionic 5

                            dev_lak 1 Reply Last reply Reply Quote 0
                            • dev_lak
                              dev_lak @oditha last edited by

                              @oditha wade hari giyada?

                              oditha 1 Reply Last reply Reply Quote 0
                              • oditha
                                oditha Web Development @dev_lak last edited by

                                @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?

                                dev_lak 1 Reply Last reply Reply Quote 0
                                • dev_lak
                                  dev_lak last edited by

                                  a machna auth eka import auth from 'firebase/app'; meken enne

                                  1 Reply Last reply Reply Quote 0
                                  • dev_lak
                                    dev_lak @oditha last edited by

                                    @oditha web client id eka firebase eke google login ekt gyama penwnwa

                                    oditha 1 Reply Last reply Reply Quote 0
                                    • oditha
                                      oditha Web Development @dev_lak last edited by

                                      @dev_lak Me dekma hri. mama meka try karala feedback ekak dennam. again thank you very much for the help.

                                      dev_lak 1 Reply Last reply Reply Quote 1
                                      • dev_lak
                                        dev_lak @oditha last edited by

                                        @oditha elama

                                        oditha 1 Reply Last reply Reply Quote 0
                                        • oditha
                                          oditha Web Development @dev_lak last edited by

                                          @dev_lak mekedi android source eka patten karanna monwa hri thiyenwada? meka dala test karama splash screen eke nawatila thiyenwa

                                          dev_lak 1 Reply Last reply Reply Quote 0
                                          • oditha
                                            oditha Web Development last edited by

                                            Me kotasa add karagen passe ionic serve run karama blank black page ekak enne browser eket

                                            oditha 1 Reply Last reply Reply Quote 0
                                            • 1
                                            • 2
                                            • 1 / 2
                                            • First post
                                              Last post

                                            1
                                            Online

                                            3.7k
                                            Users

                                            1.3k
                                            Topics

                                            5.3k
                                            Posts

                                            • Privacy
                                            • Terms & Conditions
                                            • Donate

                                            © Copyrights and All right reserved Lanka Developers Community

                                            Powered by Axis Technologies (PVT) Ltd

                                            Made with in Sri Lanka

                                            | |