baumblatt / capacitor-firebase-auth Goto Github PK
View Code? Open in Web Editor NEWCapacitor Firebase Authentication Plugin
License: MIT License
Capacitor Firebase Authentication Plugin
License: MIT License
Hi,
First off I want to say thanks for the plugin Ive gone through most of your stuff between the forums and the slack capacitor channel and I can see you've already dealt with the issue Ive been looking into in regards to firebase and auth!
Ive started looking into your plugin but I've run into an issue when trying to implement it.
My project is built in Angular 6/7 using AngularFire to connect to firebase.
I init angularFire within the app.module.ts like so
AngularFireModule.initializeApp(environment.firebase),
But when I try run the android app to connect the app to firebase it closes straight with the error below.(If you need any more info let me know)
Looking at the error it seems that the .initializeApp() function doesnt get called or possibly my placement is wrong?
D/Capacitor: Registering plugin: CapacitorFirebaseAuth
D/CapacitorFirebaseAuth: Retrieving FirebaseAuth instance
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.testapp, PID: 31894
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.testapp/com.example.testapp.MainActivity}: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.example.testapp. Make sure to call FirebaseApp.initializeApp(Context) first.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2946)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3046)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1688)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6798)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.example.testapp. Make sure to call FirebaseApp.initializeApp(Context) first.
at com.google.firebase.FirebaseApp.getInstance(com.google.firebase:firebase-common@@16.0.2:240)
at com.google.firebase.auth.FirebaseAuth.getInstance(Unknown Source:1)
at com.baumblatt.capacitor.firebase.auth.CapacitorFirebaseAuth.load(CapacitorFirebaseAuth.java:47)
at com.getcapacitor.PluginHandle.load(PluginHandle.java:72)
at com.getcapacitor.PluginHandle.<init>(PluginHandle.java:44)
at com.getcapacitor.Bridge.registerPlugin(Bridge.java:381)
at com.getcapacitor.Bridge.registerAllPlugins(Bridge.java:345)
at com.getcapacitor.Bridge.<init>(Bridge.java:156)
at com.getcapacitor.BridgeActivity.load(BridgeActivity.java:84)
at com.getcapacitor.BridgeActivity.init(BridgeActivity.java:64)
at com.example.testapp.MainActivity.onCreate(MainActivity.java:17)
at android.app.Activity.performCreate(Activity.java:7003)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1230)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2899)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3046)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1688)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6798)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
The Firebase iOS specific configurations specifies you should add Firebase/Core
and Firebase/Auth
to your podfile:
target 'App' do
capacitor_pods
# Add your Pods here
pod 'Firebase/Core'
pod 'Firebase/Auth'
end
However running npx cap sync ios
automatically adds CapacitorFirebaseAuth
to your capacitor_pods
.
pod 'CapacitorFirebaseAuth', :path => '../../node_modules/capacitor-firebase-auth'
Afterwards the iOS build fails with the following errors:
GoogleProviderHandler.swift:7:76:
Use of undeclared type 'GIDSignInUIDelegate'
node_modules/capacitor-firebase-GoogleProviderHandler.swift:18:19:
Value of type 'GIDSignIn?' has no member 'uiDelegate'
node_modules/capacitor-firebase-GoogleProviderHandler.swift:41:126:
Extra argument 'sourceApplication' in call
If I remove pod 'CapacitorFirebaseAuth', :path => '../../node_modules/capacitor-firebase-auth'
and run pod install
, the project builds again.
However I now get the runtime error undefined is not an object (evaluating 'plugin.signIn')
when calling cfaSignIn('google.com')
in my app.
Hello @baumblatt,
I follow the instruction but I have no android/app/src/main/res/values/ids.xml so I created it and put this (note: I app id is fictitious)
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="facebook_app_id">1421767639999999</string>
<string name="fb_login_protocol_scheme">fb1421767639999999://authorize</string>
</resources>
Did I dot it right? maybe this was the cause of the error
I got this error when using google
2019-09-12 08:28:12.622 18303-18428/ph.bai.pusoypinoy E/Capacitor: JavaScript Error: {"type":"js.error","error":{"message":"Uncaught [object Object]","url":"http://localhost/vendors.8b2e6d520fe27b1149a6.bundle.js","line":6767,"col":224415,"errorObject":"{\"message\":\"Google Sign In failure.\"}"}}
I have follow the instruction
any idea what I am missing?
Hi,
Would you like some help to code these?
Hi again @baumblatt!
I've been thinking of a simple way to connect Angular Fire without bother too much and I would like to know your opinion about this:
I think that signInWithCustomToken
can support this, I'm not sure tho.
What do you think?
First of all, thanks for this great work !
The issue is generated with the following steps:
There is an error with message
⚡️ To Native -> CapacitorFirebaseAuth signIn 9953204
Ops, there is no saved call building result
I have to close the app and then the signIn works well
Hi! Thank you for very nice app !!
I want to get below info from twitter login user .
screen_name
/ name
/ description
/ profile_image_url_https
/ profile_banner_url
I think result.additionalUserInfo.profile
contain these info. How can I get this ?
Maybe here, this result
contain result.additionalUserInfo.profile
.
capacitor-firebase-auth/src/facades.ts
Line 78 in 60b86da
But only return userCredential.user
here ? right ?
capacitor-firebase-auth/src/facades.ts
Line 85 in 60b86da
Hi @baumblatt!
First, thanks for the great work, it's awesome to have this plugin.
I see that you have the Email/Password
provider in the next steps,
is there any ETA on your mind?
we do use that one and I just wonder if we could expect something soon
or if we should use the available ones only.
Thank you very very much.
P/S. enable the FUNDING.yml for this plugin please ;)
i have a react+capacitor project which already compiled it to a proper android version.
after i only did:
npm install --save capacitor-firebase-auth
npx cap copy
npx cap sync
it's all become buggy!
the android studio run error after error, and i couldn't build and run my project in android anymore!
first of all, when i install it, the first bug is that it doesn't recognize the capacitor-firebase-auth path!
error 1:
ERROR: Cause: startup failed:
script 'C:\inetpub\wwwroot\Gulo\client\android\capacitor.settings.gradle': 6: unexpected char: '' @ line 6, column 107.
apacitor-firebase-auth/android\capacitor
that's because the path in: android/capacitor.settings.gradle is wrong! the /(slash) is on it opposite and it breaks the path! i should fix it anytime i sync the cap!
error 2:
because i have also a cordova barcode scanner, there's class Duplication with the com.google.zxing.
i should fix it inside the:
node_modules/capacitor-firebase-auth/capacitor-firebase-auth/build.gradle
and change the FacebookSDK from 5.0.0 into 4.25.0
error 3:
after few hours when i fixed it all, i get another error and i can't handle it anymore! i drop this package, it's so buggy!!!
the bug
org.gradle.execution.MultipleBuildFailures: Build completed with 1 failures.
at org.gradle.initialization.DefaultGradleLauncher$ExecuteTasks.run(DefaultGradleLauncher.java:358)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:300)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:292)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:174)
etc....
and i cannot handle it anymore!
I had a silent failure where I tried to sign in with google on android, and the plugin call didn't start the authentication flow and didn't return a success or failure.
Usually it works fine, and unfortunately I can't reproduce the issue. But looking through the code, should handleOnActivityResult in GoogleProviderHandler.java have a plugin.handleFailure in the event that account==null? I'm not sure if this ever arises, but if it did, that would be one explanation for how my silent failure could have occurred.
Hi @baumblatt,
Thanks for this plugin. I recently had a build error in ios, when I added capacitor fcm plugin.
The error is like below
Use of undeclared type 'GIDSignInUIDelegate'
Value of type 'GIDSignIn?' has no member 'uiDelegate'
Extra argument 'sourceApplication' in call
in GoogleProviderHandler
I did not use google authentication at all, Basically I would like to use only the login by phone, But, even put in capacitor.congif.json the only provider "phone", your plugin keep the others interface like twitter, facebook and google. Kindly advice
My application info:
Found 2 Capacitor plugins for android:
capacitor-fcm (0.0.7)
capacitor-firebase-auth (0.1.6)
Found 3 Cordova plugins for android
card.io.cordova.mobilesdk (2.1.0)
cordova-plugin-calendar (5.1.4)
cordova-plugin-stripe (1.5.3)
Found 1 incompatible Cordova plugin for android, skipped install
cordova-plugin-applepay (5.0.0)
Found 2 Capacitor plugins for ios:
capacitor-fcm (0.0.7)
capacitor-firebase-auth (0.1.6)
Found 4 Cordova plugins for ios
card.io.cordova.mobilesdk (2.1.0)
cordova-plugin-applepay (5.0.0)
cordova-plugin-calendar (5.1.4)
cordova-plugin-stripe (1.5.3)
Capacitor info:
Installed Dependencies:
@capacitor/cli 1.1.1
@capacitor/core 1.1.1
@capacitor/android 1.1.1
@capacitor/ios 1.1.1
Hi, facebook and google works great, but I can't get Twitter to work.
To Native -> CapacitorFirebaseAuth signIn 107089977 2019-10-26 17:59:19.159694+0200 App[44511:651065] [TwitterKit] Error obtaining user auth token. There is no session in Twitter sign in. ERROR MESSAGE: {"message":"There is no session in Twitter sign in.","errorMessage":""}
Hello and thanks for developing the plugin.
I am currently trying to build an Ionic/capacitor app using Firebase PhoneAuth for the users to register and log in (as I mentioned in the previous issue concerning Web version). Now I set up everything and uploaded it to TestFlight and downloaded it to my iPhone X. The app starts without any issues and I can enter my number in an input field. A button triggers a function, in which I am trying to use you plugin functionalities. Maybe I am not understanding everything right from your documentation, because the app crashes the very moment I hit the button.
Here you can see my .ts file with that function:
import {Component, OnInit} from '@angular/core';
import {cfaSignInPhoneOnCodeSent, cfaSignIn} from 'capacitor-firebase-auth';
@Component({
selector: 'app-phone-number',
templateUrl: './phone-number.page.html',
styleUrls: ['./phone-number.page.scss'],
})
export class PhoneNumberPage implements OnInit {
phoneNumber: string;
verificationIdOutput: any;
constructor() { }
ngOnInit() {
}
sendPhone() {
console.log('Attempting to send phone number: ' + this.phoneNumber); // This gets printed on console, when I run it in browser, but I know it crashes from that point in browser from not supporting WebBrowsers
cfaSignIn('phone', { phone : this.phoneNumber }).subscribe(
user => {
console.log('User: ' + user.phoneNumber);
console.log('Sent number ' + this.phoneNumber + ' successfully!');
}
);
cfaSignInPhoneOnCodeSent().subscribe(
verificationId => {
console.log(verificationId);
}
);
}
}
See my capacitor.config.json:
{
"appId": some.app.id",
"appName": "AppName",
"bundledWebRuntime": false,
"npmClient": "npm",
"webDir": "www",
"plugins": {
"CapacitorFirebaseAuth": {
"providers": ["phone"],
"languageCode": "en",
"nativeAuth": false,
"permissions": {}
}
}
}
I am very happy to provide further information, if necessary!
Thanks in advance!
I have a problem when singing up with google. The page redirects to wrong page.
So in my code I call:
var provider = new firebase.auth.GoogleAuthProvider();
firebase.auth().singUpWithPopup(provider).then(result=>mylogic)
What happens on the mobile versions of the app is that there are no pop ups with
google mail options or anything like that.
I tried both 'nativeAuth':true/false in capacitor.config.json.
Could you help me out with this issue.
Best regards, Milos
Hello Bernado, one question to the token ... I use Google as provider and try to get data from a Google API with the stsTokenManager.accessToken value. Is it the right one? I do not get any result but a 401 (the API in general works with original Google signin / token creation).
I have tried several times to setup as explained, but I keep getting this error:
[error] - {"line":17,"column":28716,"sourceURL":"capacitor://localhost/build/p-05bb7ce0.js"}
⚡️ ------ STARTUP JS ERROR ------
⚡️ TypeError: undefined is not an object (evaluating 'M.signIn')
⚡️ URL: capacitor://localhost/build/p-4c7259e1.js
⚡️ p-4c7259e1.js:1840:1810
Do you have any idea where could be the problem?
I am trying to login using a Stenciljs app.
Thanks!
i understand that cfaSignInPhoneOnCodeReceived this will auto login the user so there is no need to do something else.
cfaSignInPhone where should it be used?
I am using google login and it seems the plugin doesn't handle a scenario when application was signed in, but the token has expired already (it is valid for 1 hour). I had to add the following branch to GoogleProviderHandler.java (to "public bool isAuthenticated()"):
if (account != null)
{
String token = account.getIdToken();
if (token == null)
account = null;
else
{
account = null;
JWT jwt = new JWT(token);
boolean isExpired = jwt.isExpired(10);
if (isExpired)
{
Log.d(GOOGLE_TAG, "Google silentSignIn result.");
try {
Task<GoogleSignInAccount> task = this.mGoogleSignInClient.silentSignIn();
account = task.getResult(ApiException.class);
} catch (ApiException exception) {
}
}
}
}
BTW, I am using com.auth0.android.jwt.JWT (dependency is 'com.auth0.android:jwtdecode:1.3.0')
Hi Bernardo,
node_modules/capacitor-firebase-auth/dist/esm/facades.d.ts(1,27): error TS2307: Cannot find module 'firebase/app'
...will still occur in AngularFire2 projects during the build process.
Best Regards
André
The user has to authorize the application everytime after a signout. With firebase web I don't have this issue.
Any idea what the problem might be?
I read there are 2 urls, authorize and authenticate. But the TwitterLoginButton seems to only have an authorize method.
Best regards,
Ryan
Please, close this issue.
I got this error when running android studio. Any idea what I miss?
error: package com.baumblatt.capacitor.firebase.auth does not exist
in my android/app/src/main/java/ph/bai/pusoypinoy/MainActivity.java
package ph.bai.pusoypinoy;
import android.os.Bundle;
import com.getcapacitor.BridgeActivity;
import com.getcapacitor.Plugin;
import com.baumblatt.capacitor.firebase.auth.CapacitorFirebaseAuth;
import java.util.ArrayList;
public class MainActivity extends BridgeActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Initializes the Bridge
this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
// Additional plugins you've installed go here
// Ex: add(TotallyAwesomePlugin.class);
add(CapacitorFirebaseAuth.class);
}});
}
}
Is there a way to add scopes like https://www.googleapis.com/auth/drive
when signing in to Google?
For example, when using firebase.auth().signInWithPopup
directly, you can use addScope
like:
let provider = new firebase.auth.GoogleAuthProvider();
provider.addScope('https://www.googleapis.com/auth/drive');
provider.addScope('https://www.googleapis.com/auth/drive.file');
let response = await firebase.auth().signInWithPopup(provider);
I can login fine via cfaSignInGoogle
but want to make sure the user has the correct permissions.
Good morning!
First of all, you are doing great work!
I'm using your plugin to sign in / sign out with google. When I try to sign out with cfaSignOut().subscribe();
an exception it is produced:
2019-12-20 10:12:17.115 32204-32308/com.example.app E/Capacitor: Unable to execute plugin method com.getcapacitor.PluginInvocationException: Unable to invoke method signOut on plugin
However, afterwards it indicates that it has been sign out successfully:
2019-12-20 10:12:17.116 32204-32204/es.gasexpress.app I/GoogleProviderHandler: Google Sign Out succeed.
There is the full trace:
2019-12-20 10:12:17.088 32204-32349/com.example.app V/Capacitor/Plugin: To native (Capacitor plugin): callbackId: 20739297, pluginId: CapacitorFirebaseAuth, methodName: signOut
2019-12-20 10:12:17.088 32204-32349/com.example.app V/Capacitor: callback: 20739297, pluginId: CapacitorFirebaseAuth, methodName: signOut, methodData: {}
2019-12-20 10:12:17.115 32204-32308/com.example.app E/Capacitor: Unable to execute plugin method
com.getcapacitor.PluginInvocationException: Unable to invoke method signOut on plugin com.baumblatt.capacitor.firebase.auth.CapacitorFirebaseAuth
at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:101)
at com.getcapacitor.Bridge$2.run(Bridge.java:537)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.os.HandlerThread.run(HandlerThread.java:67)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:99)
at com.getcapacitor.Bridge$2.run(Bridge.java:537)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.os.HandlerThread.run(HandlerThread.java:67)
Caused by: The SDK has not been initialized, make sure to call FacebookSdk.sdkInitialize() first.
at com.facebook.internal.Validate.sdkInitialized(Validate.java:144)
at com.facebook.login.LoginManager.<init>(LoginManager.java:80)
at com.facebook.login.LoginManager.getInstance(LoginManager.java:93)
at com.baumblatt.capacitor.firebase.auth.handlers.FacebookProviderHandler.signOut(FacebookProviderHandler.java:75)
at com.baumblatt.capacitor.firebase.auth.CapacitorFirebaseAuth.signOut(CapacitorFirebaseAuth.java:127)
at java.lang.reflect.Method.invoke(Native Method)
at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:99)
at com.getcapacitor.Bridge$2.run(Bridge.java:537)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.os.HandlerThread.run(HandlerThread.java:67)
2019-12-20 10:12:17.116 32204-32204/com.example.app I/GoogleProviderHandler: Google Sign Out succeed.
It is trying to log out from facebook maybe?
Thank you in advance!
I'm getting this error message when I'm trying to sign in. In testing environment (Android Studio) everything works fine, but when I'm trying to sign in production mode (download from Play Store) I'm getting this message. I tried both nativeAuth : true/false in CapacitorFirebaseAuth. Is this something that has a connection with permisssions? Error message is not as descriptive.
Best regards
Hi,
it would be great to include also the Signin with Email link workflow in the plugin.
I have been trying to configure the Firebase Dynamic Links to work with Capacitor, but after some trials I am stuck :).
Thanks!
Luca
I made an application with google sign-in but it doesn't launch. Its build worked without any error. When I run the APK, Application will shut down immediately. I couldn't get any error code(I tried USB debug and emulator).
I'm using an Android device. I could see the app work only in localhost (npm run serve) and got this error.
[Vue warn]: Error in v-on handler: "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()."
found in
---> at src/components/Auth4.vue
at src/App.vue
Any advice?
Thanks for wonderful plugin..
When I signed in Using phone number authentication I received sms like below..
**I received sms with a portugese language.. ** ONLY IN ANDROID
Would you kindly advice what to do?
PluginDetails:
capacitor-firebase-auth (0.1.4)
Capacitor details:
@capacitor/cli: 1.1.0
@capacitor/core: 1.1.0
@capacitor/android: 1.1.0
@capacitor/ios: 1.1.0
Hello ,
I have followed the instruction in the documentation but i am getting this error
Either an instance of firebase.auth.Auth must be p…must be initialized via firebase.initializeApp().
doLogin() { cfaSignIn('phone', { phone : '+111' }).subscribe( user => { console.log('User: ' + user.phoneNumber); console.log('Sent number ' + '+111' + ' successfully!'); } ); cfaSignInPhoneOnCodeSent().subscribe( verificationId => { console.log(verificationId); } ); }
, please note i am testing from browser .
Please, close this issue.
Hello Baumblatt,
I am trying to use your plugin in order to use Firebase Phone Auth with my Ionic 4 project.
The steps I have taken so far:
I initialized my app (successfully) with Firebase via
imports: [
...
AngularFireModule.initializeApp(firebaseConfig),
...
],
and it works by redirecting me to my login page with AngularFireAuthGuard, so Firebase connection should not be an issue here.
Then, I ran
npm install --save capacitor-firebase-auth
and configured my capacitor.config.json like that:
{
"appId": "...",
"appName": "...",
"bundledWebRuntime": false,
"npmClient": "npm",
"webDir": "www",
"plugins": {
"CapacitorFirebaseAuth": {
"providers": ["phone"],
"languageCode": "en",
"nativeAuth": false,
"permissions": {}
}
}
}
I also followed step 2 and 3 from your documentation, which is to add some information to the Android files (I am only trying to set up Web version for now, but did this anyways).
Next, I activated phone authentication in my Firebase Console.
Finally, on my login page, I have the following code
phoneNumber: string; // this is two-way-binded to an input
sendPhone() {
console.log('Attempting to send phone number: ' + this.phoneNumber);
cfaSignIn('phone', { phone : this.phoneNumber }).subscribe(
user => {
console.log(user.phoneNumber)
console.log('Number: ' + this.phoneNumber + ' sent successfully'),
cfaSignInPhoneOnCodeSent().subscribe(
verificationId => console.log('Verification code received: ' + verificationId)
);
}
);
}
The function is triggered via a button and logs the first "Attempting to send phone number: XXX", but then throws me an error in my firefox console on my laptop:
ERROR CapacitorFirebaseAuth does not have web implementation.
I am pretty lost and don't have any idea what could cause this issue.. If further information is needed, just let me know!
Thanks in advance!
Please, close this issue.
hi,
I got an error with add(CapacitorFirebaseAuth.class) in MainActivity.java, it needs an import which I don't know the name.
Hello, first of all, thanks for your plugin !
Since your last release (0.3.0), there is an error when I build.
Notice that I have updated firebase to the latest version as well (7.6.1):
ERROR in node_modules/capacitor-firebase-auth/dist/esm/facades.d.ts:1:8 - error TS1259: Module '"c:/Users/xxxxx/code/ngx-mmm/node_modules/firebase/index"' can only be default-imported using the 'allowSyntheticDefaultImports' flag
1 import firebase from 'firebase/app';
This can be corrected by changing:
import firebase from 'firebase/app';
to:
import * as firebase from 'firebase/app';
in node_modules/capacitor-firebase-auth/dist/esm/facades.d.ts
Hey, thanks for the useful plugin :-)
I stuggle to sign in to Google from a Vue app without typescript support. My code:
import Firebase from 'firebase/app'
import {cfaSignIn} from 'capacitor-firebase-auth';
...
Firebase.initializeApp(...)
...
cfaSignIn('google.com').subscribe((user) => {
this.$f7.dialog.alert('Display Name: ' + user.displayName)
})
I think it's used wrong as in the example the User object is somehow used.
Capacitor config:
Error in the browser:
Error in the Xcode logs:
Hi Bernardo,
Just wanted to let you know the I am putting an app that uses your plugin into production tomorrow the 22/11/19. The app uses the Google and Facebook auth. Will let you know if any users run into any issues but all my testing has been good so far.
Thank you for creating such a great plugin!
Regards,
Trent
Hi there,
I successfully managed to integrate this library into my app. The facebook authentication works on a real iOS device.
However on android, I see the error message "This app has no Android key hashes configured. Configure your app key hashes at FACEBOOK_APP_LINK".
When i go to the facebook dashboard page, and browse through every available page, I cant see any mention of "Android key hashes" - there's no field for such a thing.
Do I need to have an in-production facebook-verified app before the field appears or something?
I followed the "android getting started" guide on the facebook website, here:
https://developers.facebook.com/docs/android/getting-started/#create_hash
which then shows you how to set up the fields using sample app here:
https://developers.facebook.com/docs/android/getting-started/#samples
Which shows you how to generate a key & hash, but then you put it in some custom "sample apps" tab in the website. So its not clear from the guides or documentation where a real app Android key hash should go.
Any advice?
Thanks!
Hi,
I need to know when the SMS is sent to user and only then activate the enter PIN code form. So I wrote the following:
cfaSignInPhone(number).subscribe(
(user) => {
console.log('Sent code to number ' + user.phoneNumber + ' successfully!');
// activate enter code form
},
(error) => {
setFireBaseError("coulnd't send SMS to phone number because of " + error);
},
//complete()
() => {console.log("Send SMS code complete was called")}
);
However this doesn't work as (user)=> {...} or complete() are not always called. I have noticed that they are some times called and some other times not. Could it be because I'm sometimes using a while-listed number? I'm sure whitelisted numbers don't call the above mentioned methods however I'm not yet fully sure if they do with real numbers (because of too many failed attempts firebase has blocked my numbers for the time being so I can't check). It would be nice to add support for white-listed number at least so that for development we wouldn't need to use real numbers and get blocked.
I face this error after install and set up the capacitor-firebase-auth. I found this issue about the same error on facebookarchive/facebook-swift-sdk#458
Can someone help me please?
I uploaded my Capacitor App to App store and receive a warning from Apple. I have checked the source code and realize that this plugin is using UIWebView. Here is the message from Apple.
ITMS-90809: Deprecated API Usage - Apple will stop accepting submissions of apps that use UIWebView APIs . See https://developer.apple.com/documentation/uikit/uiwebview for more information.
For now, I have no idea how to achieve this. I hope someone may face the same problem and let me know how you resolved it.
When i add the plugin in MainActivity.java i get this warn from the editor.
The application builds successfully but I don't know if this is right.
I have another problem that could be related. Should i open another issue? Sorry I don't know the etiquette for that 🙃
After cfaSignInPhoneOnCodeReceived:
ERROR Error: Uncaught (in promise): FirebaseError: Firebase: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() (app/no-app).
FirebaseError: Firebase: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() (app/no-app).
Apple now ask for their "Sign In With Apple" service to be included with any new app that exclusively offers other social logins. Firebase recently added support for Apple Sign In, so it would be great if this plugin were updated to also support Apple.
When the user cancels the Google signup process in iOS, I'm not getting a reject() callback. It looks like the error is printed out and silently thrown away:
func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) {
if let error = error {
print(error.localizedDescription)
return
}
We are building an Ionic Stencil (no framework) app using Capacitor (hybrid mobile app).
So far, I'm loving this plugin (I only have a working build in Android so far). Great job unifying the login approach for all of the different providers. It initially took me awhile to get things working. I found that the following import in facades.js
was causing the above error.
import * as firebase from 'firebase/app';
And this is because firebase.auth
in firebase.auth.GoogleAuthProvider().providerId
was undefined.
So, I changed it to:
import firebase from '@firebase/app';
And now the reference to the provider is valid. I don't fully understand why this is happening. Can you give me some guidance for how to deal with this properly? Maybe I should be using a different version of com.google.firebase:firebase-auth:17.0.0
? I downgraded to this version because the latest version was causing some manifest merge issues related to AndroidX.
Here are the dependencies I'm using:
Root level gradle has: classpath 'com.google.gms:google-services:4.3.2' // Google Services plugin
App level gradle has:
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation project(':capacitor-android')
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation project(':capacitor-cordova-android-plugins')
implementation 'com.google.firebase:firebase-auth:17.0.0'
implementation 'com.facebook.android:facebook-android-sdk:4.41.0'
}
package.json
"dependencies": {
"@capacitor/android": "^1.3.0",
"@capacitor/core": "1.2.1",
"@capacitor/ios": "^1.3.0",
"@ionic/core": "^4.11.3",
"@stencil/state-tunnel": "^1.0.1",
"@types/jest": "^24.0.21",
"animate.css": "^3.7.2",
"capacitor-firebase-auth": "^0.2.4",
"firebase": "^6.6.1",
"moment": "^2.24.0",
"prettier": "^1.18.2"
},
Please advise?
How does this project compare to this: https://firebase.google.com/docs/auth/web/cordova used with capacitor? Doesn't it work to use firebase auth integration of cordova with ionic's capacitor? Thanks
Hi, I'm trying to do phone verification and none of the .subscribe()
methods return the values they are supposed to. For example:
cfaSignInPhone(number).subscribe(
user => {
console.log('Sent to number ' + user.phoneNumber + ' successfully!');
}
);
Actually sends the SMS but console.log is never called. I have the same situation with cfaSignInPhoneOnCodeSent().subscribe()
after I get the code and need to verify it.
What am I doing wrong?
Hello,
Im having trouble understanding how to implement phone auth properly.
I created this function:
doLogin() {
cfaSignIn('phone', { phone : this.phoneNumber }).subscribe(
user => {
console.log('User: ' + user.phoneNumber);
console.log('Sent number ' + this.phoneNumber + ' successfully!');
}
);
cfaSignInPhoneOnCodeSent().subscribe(
verificationId => {
console.log(verificationId);
}
);
}
}
Ive taken all the steps for IOS, the code builds fine and i can run it on my iphone.
The console.log's are not showing on the output pane, but i do get this response:
{"verificationId":"AM5P..longstring...qzw"}
What am i suppose to do now? am i signed in?.. then how can i get my firebase user ID for example? Is cfaSignInPhoneOnCodeSent actually needed since cfaSignIn allready gives me a verificationId?
A more complete code example would be awesome. Also a working code example that includes IOS and Android as well as web.
Kind regards,
Alex
Hi,
i tried your plugin in real phone, iOS with capacitor and could not login using phone authentication from firebase.
after checking the documentation
i used this:
cfaSignIn('phone', { phone: "+301234511223" }).subscribe(
user => {
console.log(user.phoneNumber)
}
)
next the following code got me the verificationId:
cfaSignInPhoneOnCodeSent().subscribe(
async verificationId => {
console.log("cfaSignInPhoneOnCodeSent")
console.log(verificationId)
this.showCodeInput = true;
}
)
then, i received the sms and used the code in my showCodeInput area like this:
await cfaSignInPhone("+301234511223", this.verificationCode);
console.log('Login finished.');
there is not in the documentation how to signIn using the verificationCode.
Could someone help me what i am doing wrong?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.