GithubHelp home page GithubHelp logo

Comments (10)

LeXXik avatar LeXXik commented on July 17, 2024 3

Since my app is an HTML5 canvas game and the native layer seem to be working, I went ahead and boot up a local server to get a better look into the problem. The root cause was here
image

I checked the line 30 in facades.js, which is here:

const phoneProvider = new firebase.auth.PhoneAuthProvider().providerId;

So, the problem was that the Phone provider was initializing, regardless if I actually need it or not. I assume the crash was due to the phone provider missing a configuration? Not sure, and don't care, actually, since I only need Google sign-in.

So, instead of passing the auth provider id, using

"use strict";
exports.__esModule = true;

var auth = require("capacitor-firebase-auth");
auth.cfaSignIn('google.com').subscribe(function(user) { 
    console.log(user.displayName); 
  }
)

I call the google sign-in method directly:

"use strict";
exports.__esModule = true;

var auth = require("capacitor-firebase-auth");
auth.cfaSignInGoogle().subscribe(function(user) {
    console.log(user.displayName);
  }
)

It works now.

from capacitor-firebase-auth.

baumblatt avatar baumblatt commented on July 17, 2024

Hi Yuki,

There is a good discussion about firebase App not initialized at issue #1 .

Did you got any exception in logcat?

Best Regards,
Bernardo Baumblatt

from capacitor-firebase-auth.

baumblatt avatar baumblatt commented on July 17, 2024

Hi Yuki,

Did you solve your issue? If not, can you shared the your logcat?

Best regards,
Bernardo Baumblatt.

from capacitor-firebase-auth.

piotrzuzak avatar piotrzuzak commented on July 17, 2024

Hi @baumblatt,

My context:

  1. Application does not crash after adding plugin (I am not sure if plugin is loaded correctly Futuny starting)
  2. Application has google-services.json exported from firbase console to level of "android/app"
  3. Application's google-services.json has SHA-1 and configured Firebase Android Application according to instructions

Issur:

  1. I am getting the same exception on logcat console as @minaph:

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()

Below all logs (logcat) under "firebase" key from search input:

2019-10-14 22:08:42.152 8850-8870/com.fasttrack.app W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
2019-10-14 22:08:42.187 8850-8850/com.fasttrack.app D/FirebaseApp: com.google.firebase.crash.FirebaseCrash is not linked. Skipping initialization.
2019-10-14 22:08:42.188 8850-8850/com.fasttrack.app D/FirebaseApp: com.google.android.gms.measurement.AppMeasurement is not linked. Skipping initialization.
2019-10-14 22:08:42.188 8850-8850/com.fasttrack.app I/FirebaseInitProvider: FirebaseApp initialization successful
2019-10-14 22:08:42.209 8850-8873/com.fasttrack.app W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
2019-10-14 22:08:42.241 8850-8873/com.fasttrack.app I/FirebaseAuth: [FirebaseAuth:] Loading module via FirebaseOptions.
2019-10-14 22:08:42.242 8850-8873/com.fasttrack.app I/FirebaseAuth: [FirebaseAuth:] Preparing to create service connection to gms implementation
2019-10-14 22:08:43.874 8850-8850/com.fasttrack.app D/Capacitor: Registering plugin: CapacitorFirebaseAuth
2019-10-14 22:08:43.883 8850-8850/com.fasttrack.app D/CapacitorFirebaseAuth: Verifying if the default FirebaseApp was initialized.
2019-10-14 22:08:43.885 8850-8850/com.fasttrack.app D/CapacitorFirebaseAuth: Retrieving FirebaseAuth instance
2019-10-14 22:08:43.885 8850-8850/com.fasttrack.app D/CapacitorFirebaseAuth: Initializing Google Provider
2019-10-14 22:08:43.921 8850-8850/com.fasttrack.app D/CapacitorFirebaseAuth: Google Provider Initialized

Please help!

from capacitor-firebase-auth.

baumblatt avatar baumblatt commented on July 17, 2024

from capacitor-firebase-auth.

piotrzuzak avatar piotrzuzak commented on July 17, 2024

Hi @baumblatt,

Thank you for your respond. Let's clarify some things:

  1. I need only google and facebook option - these ones are configured through firebase
  2. I don't need phone provider as authentication should be based on firebase authentication only, without any phone step verification
  3. Here is capacitor config:

{
"appId": "com.fasttrack.app",
"appName": "FasttrackApp",
"bundledWebRuntime": false,
"npmClient": "npm",
"webDir": "www",
"plugins": {
"SplashScreen": {
"launchAutoHide": false
},
"CapacitorFirebaseAuth": {
"providers": ["google.com"],
"languageCode": "en",
"nativeAuth": false,
"permissions": {
"google": ["profile"]
}
}
}
}

  1. I've added source code with all commits with steps one by one to public repo on github. you can download it directly and check on your own => https://github.com/piotrzuzak/ionic-firebase-capacitor-test

PS. I've tried with 'phone' key adding but without success

Thank you in advance

from capacitor-firebase-auth.

baumblatt avatar baumblatt commented on July 17, 2024

Hi @piotrzuzak ,

Thank you by sharing your project, otherwise, I would never has figured out that the problem was rising on web tier before calling the native tier.

In your case, that use AngularFire, you need to init the Firebase App like described here:
4. Add Firebase config to environments variable
5. Setup @NgModule for the AngularFireModule

I look forward to hearing about your tests.

If you like this plugin, please don't forget to put a star the project to help others to find it.

Best regards,
Bernardo Baumblatt

from capacitor-firebase-auth.

LeXXik avatar LeXXik commented on July 17, 2024

I have the same issue with the OP. I do not use Angular/React, as it is a an HTML5 canvas fullscreen game. One of the buttons initiate a Google sign in, which I use the following way:

//init
firebase.initializeApp({options});

// call
cfaSignIn('google.com').subscribe(function(user) {
    console.log(user);
});

// capacitor.confiig.json
"CapacitorFirebaseAuth": {
  "providers": ["google.com"],
  "languageCode": "en",
  "nativeAuth": false,
  "permissions": {}
}

EDIT:
Here is some input from my logcat:

...
I/FirebaseInitProvider: FirebaseApp initialization successful
I/FacebookInitProvider: Failed to auto initialize the Facebook SDK
...
I/FirebaseAuth: [FirebaseAuth:] Preparing to create service connection to gms implementation
...
D/Capacitor: Starting BridgeActivity
D/Capacitor: Registering plugin: App
...
D/Capacitor: Registering plugin: CapacitorFirebaseAuth
D/CapacitorFirebaseAuth: Verifying if the default FirebaseApp was initialized.
    Retrieving FirebaseAuth instance
    Initializing Google Provider
D/GoogleProviderHandler: Google Api is Available.
D/CapacitorFirebaseAuth: Google Provider Initialized
...
D/Capacitor: Loading app at http://localhost
...
D/Capacitor: Handling local request: http://localhost/
...
D/Capacitor/Plugin/LN: LocalNotification received: null
D/Capacitor/Plugin/LN: Activity started without notification attached
...
D/Capacitor: App started
D/Capacitor/Plugin/App: Firing change: true
V/Capacitor/Plugin/App: Notifying listeners for event appStateChange
D/Capacitor/Plugin/App: No listeners found for event appStateChange
V/FA: Activity resumed, time: 38378745
D/Capacitor: App resumed
...
D/Capacitor: Handling local request: http://localhost/start-script.js
...
E/Capacitor: JavaScript Error: {"type":"js.error","error":{"message":"Uncaught 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().","url":"http://localhost/start-script.js","line":7576,"col":7,"errorObject":"{\"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().\"}"}}
E/Capacitor/Console: File: http://localhost/start-script.js - Line 7576 - Msg: Uncaught 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().

from capacitor-firebase-auth.

LeXXik avatar LeXXik commented on July 17, 2024

So, I guess the native layer is working fine and the problem is in the web layer? That error is coming from firebase-auth.js. I don't use Typescript, since my project is JS. This is my start-script.js where the app crashes:

"use strict";
exports.__esModule = true;

var auth = require("capacitor-firebase-auth");
auth.cfaSignIn('google.com').subscribe(function(user) { 
    console.log(user.displayName); 
  }
)

I tried to add <script src="firebase-app.js"></script> in the index.html and init with firebase.initializeApp({...}), but that gave an error that firebase is already defined. How do I satisfy @firebase/auth.js? Looking at the error and considering I don't use a phone provider for auth, it is missing a firebase initialization. However, I am not sure where and how to point it to the current instance.

from capacitor-firebase-auth.

emaikongebm23 avatar emaikongebm23 commented on July 17, 2024

hey @LeXXik, I got an error saying:

ERROR Error: Firebase: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() (app/no-app).
    at Object.app (default~pages-authentication-authentication-module~user-user-module~web-es2015.js:366)
    at plugin.signIn.then (default~pages-authentication-authentication-module~user-user-module-es2015.js:75)
    at ZoneDelegate.invoke (polyfills-es2015.js:3470)
    at Object.onInvoke (vendor-es2015.js:64536)
    at ZoneDelegate.invoke (polyfills-es2015.js:3469)
    at Zone.run (polyfills-es2015.js:3229)
    at zone.scheduleMicroTask (polyfills-es2015.js:3963)
    at ZoneDelegate.invokeTask (polyfills-es2015.js:3505)
    at Object.onInvokeTask (vendor-es2015.js:64524)
    at ZoneDelegate.invokeTask (polyfills-es2015.js:3504)

Did you get this error too or am I missing something here?

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.