GithubHelp home page GithubHelp logo

Phone Auth about capacitor-firebase-auth HOT 5 OPEN

baumblatt avatar baumblatt commented on August 16, 2024
Phone Auth

from capacitor-firebase-auth.

Comments (5)

baumblatt avatar baumblatt commented on August 16, 2024

Hello @alkahtani ,

First, sorry about, but we don’t have web implementation on this plugin, yet. But the error suggests that you are not initializing your Firebase App.

Please, follow the instructions of Add Firebase SDKs and initialize Firebase on official docs.

Don’t forget, after that, you will need to test on a phone or emulator.

Best regards,
Bernardo Baumblatt

from capacitor-firebase-auth.

tepafril avatar tepafril commented on August 16, 2024

Dear @baumblatt ,
Thank you so much for you effort to write this awesome plugin. My task is implement phone auth on both android and ios. I have followed your instruction. Unfortunately, I also received above error message from debug area in Xcode(ios), yet I haven't tried on android.

Code

cfaSignIn('phone', {"phone": "+85516827282"}).subscribe(
      user => console.log(user.phoneNumber)
);

Error
[error] - ERROR {"code":"auth/argument-error","message":"Either an instance of firebase.auth.Auth must be passed as an argument to the firebase.auth.PhoneAuthProvider constructor, or the default firebase App instance must be initialized via firebase.initializeApp()."}

I'm so glad if you could help.

Cheer,
Afril TEP

from capacitor-firebase-auth.

tepafril avatar tepafril commented on August 16, 2024

Hi everyone!

I managed to make it work now by:

1. Implementing javascript initialization from firebase. Here is the snippet:

import { Component, OnInit } from '@angular/core';
import * as firebase from 'firebase';
import {cfaSignIn} from 'capacitor-firebase-auth';

@Component({
  selector: 'app-register',
  templateUrl: './register.page.html',
  styleUrls: ['./register.page.scss'],
})
export class RegisterPage implements OnInit {

  constructor(
  ) {
  let firebaseConfig = {
    apiKey: "",
    authDomain: "",
    databaseURL: "",
    projectId: "",
    storageBucket: "",
    messagingSenderId: "",
    appId: "",
    measurementId: ""
    };
    firebase.initializeApp(firebaseConfig);
  }

  onSubmit() {
    cfaSignIn('phone', {"phone": "+85516827282"}).subscribe(
      user => console.log(user.phoneNumber)
    );
  }
}

2. Add a URL scheme to my app:
Here is their official instruction: Url Scheme

Please take a look at screenshot:
Screen Shot 2020-01-15 at 9 21 05 PM

from capacitor-firebase-auth.

GenissonAlbuquerque avatar GenissonAlbuquerque commented on August 16, 2024

I am trying to use phone authentication, but I have not been successful.
I started a blank project at Ionic Angular with Capacitor and ran folow commands:

npm install --save capacitor-firebase-auth
npx cap sync
npm install jetifier
npx jetifier
npm install --save @capacitor/core
npm install --save firebase (I installed peerdependencies myself)

my capacitor.config.json seems like:

"CapacitorFirebaseAuth": {
"providers": ["phone"],
"languageCode": "en",
"nativeAuth": false,
"permissions": {}
}

I followed instructions to install firebase on Android and put google-services.json file on Android/App.

When I tray execute de code on my login.page.ts:

cfaSignIn('phone', {phone: '+55'+phoneNumer}).subscribe(user => { console.log(user.phoneNumber); });

I receved the error:

Either an instance of firebase.auth.Auth must be passed as an argument to the firebase.auth.PhoneAuthProvider constructor, or the default firebase App instance must be initialized via firebase.initializeApp().

I think de library was waiting for firebase.initializeApp() at web layer, but I'm using Capacitor. Should I instantiate firebase.initializeApp()? (in firebase console I create only a Android config, for use firebase.initializeApp() I will need create a Web config too). How capacitor-firebase-auth phone authentication works? Native layer (Android project) or web layer (javascript)? How to make a simple ionic capacitor app login with phone authentication?

from capacitor-firebase-auth.

GenissonAlbuquerque avatar GenissonAlbuquerque commented on August 16, 2024

the solution is:

Instead of use cfaLogIn('phone', {phone: '+55'+phoneNumber}).subscribe(user => { console.log(user.phoneNumber); });

I should use cfaSignInPhone('+55'+phoneNumber).subscribe(user => { console.log(user.phoneNumber); });

from capacitor-firebase-auth.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.