-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Firebase google auth not working on Cordova/Android #203
Comments
Sorry for the delay. I am swamped with stuff lately. I didn't have the time to look at your code, but here are some tips for Cordova/Ionic apps in Android: After sign-in, are you getting redirected back to the app? |
Per your suggestion, I tried adding:
I am building with build.phonegap.com - I don't know if this has anything to do with the issue. (This is the one deviation I made from the tutorial.) Thank you for your time. I've been pulling my hair out over this, and I hope it might help other developers like me. |
I have only tested with Ionic/Cordova. I have not tested with build.phonegap.com. It may have something to do with that. I speculate the incoming link is not getting picked up. Try logging it when the app is relaunched:
|
As you speculated, the universallinks event never seems to fire (before or after authentication round trip).
(On iOS, this also never fires (I think), yet authentication works OK -- presumably iOS doesn't need universallinks in order to work?) |
iOS doesn't use universal links. It uses custom scheme redirect (cordova-plugin-customurlscheme).
Can you try testing this plugin separately (without Firebase in a basic test app) using build.phonegap.com with some universal link. It could be an issue with the plugin. |
I am also experiencing exactly the same issue. |
@wytlytningNZ, we might have slightly different issues. For mine, redirection back to the app happens OK, but no authentication event is triggered. As @bojeil-google helped narrow down, this is ultimately because the "cordova-universal-links-plugin" doesn't work on Android when building cordova app with PhoneGap Build [other case I opened for that plugin], resolution still TBD. I've started learning how to build without PGB (locally with cordova). Initial tests seem to show authentication in Android works OK that way, and confirms it is in fact related to cordova-universal-links-plugin (in)compatibility with PhoneGap Build. @wytlytningNZ - looks like @bojeil-google had some advice above for the case where redirection back to app doesn't happen. (didn't apply to me, but might apply to your case.?) @bojeil-google - since PhoneGap Build is convenient for me and others [Getting local cordova running has been quite a learning curve for me the last week!], I wanted to inquire about the possibility of changing firebase to use custom scheme urls (already supported through "cordova-plugin-customurlscheme" plugin) instead of ("https") universal-links, for Android. This would make one fewer [problematic for some] plugin dependency for full iOS/Android/Web firebase authentication. (I assume this is a long shot, but wanted to ask. It was a surprise to hear iOS & Android worked differently in that regard.) |
My recommendation is to fix the issue with the plugin to support PhoneGap Build. Unlike the App store, Android applications can be distributed without going through an app market store like the Google Play store. Any application can claim a custom scheme (that it doesn't own) and in some cases a developer has no means to take down such applications (unlike the Apple app store). https links are recommended for Android apps as custom scheme redirects are far less secure. |
@bojeil-google - got it. Thanks for the explanation on https vs custom-scheme. Possibly making progress on universal-links plugin PGB workaround, but still not quite there. |
Thanks, @blukis. If you find the correct way to configure the plugin to work for PGB, I'll make sure it's documented in our official docs for other PGB developers. |
the user does not come back in callback although it comes back when you are subscribed to check authstatus of user . and hence you can login but there is a bug that when universal plugin browser gets closed why the user does not come in callback . |
There was an issue we recently discovered and fixed in the core SDK and firebaseUI that is related to FirebaseUI in Cordova Android Apps, please update FirebaseUI-web to 2.6.0 and firebase to 4.9.1: https://github.com/firebase/firebaseui-web/releases/tag/v2.6.0 |
I had a similar issue. Not sure if this helps, but since I installed plugin code with npm install, the plugins/android.json file's "installed_plugins" property was not updated. Maybe check that file? |
You may have seen that recently the cordova-universal-links-plugin was deprecated, and it was announced that it was not going to be supported or even bug-fixed anymore, and the comment thread was closed and locked. It seems that you need to come up with some definitive alternative, and stop recommending its use, as is done here in the Firebase docs. |
Thanks for the notice @rtm. We are updating our docs. |
@blukis What I've done:
But after choosing the Google account in the auth flow, it redirects to my app without any creds. Is there anything else you've setup in your firebase app that could explain my problem? I build/compile and run locally, on-device. |
@flamz3d - would you be able to share your working code. I am struggling with the same issue. |
I have the same issue. I recieved user=null. Any suggestions? |
I am having the same issue. For me, I am having this issue on iOS. Using an angular project. I am also getting {user : null} (no creds). Trying to sign in with Google. I followed the steps here: https://firebase.google.com/docs/auth/web/cordova It happens only for new users who are signing in for the first time. And it only happens the first time I attempt to login. Once I have attempted the flow at least one, the second time it works (without asking me for a password). However, when I try to sign in with Facebook, it does not work at all. |
Same problem as well! Its not working for me on android as well. |
Like everyone else here iOS is working but not android. The docs state the following is required: using
I also forked cordova-universal-links-plugin
The before and after log message is logged but not the window.universalLinks.subscribe callback log message. After invoking: signInWithRedirect the browser goes through normal oauth flow but when the flow completes and it sends me back to the app I'm never "really" logged in.
Creating a dynamic link in firebase console redirects me to the app but the log message in subscribe block is never called. Is there a template that can be attached to https://firebase.google.com/docs/auth/web/cordova with a working setup in 2020? Is there a docker image Google uses for cordova with correct version to produce a working apk? cordova version, android sdk version ect... Thanks, |
Hi @leblancmeneses , Than you very much |
I can't get Firebase Auth (Google) to work on PhoneGap-build/Android - works great on PhoneGap/iOS, and directly on the web. (Disclosure - I don't know where to post this inquiry, please redirect me if there's a better place.)
For an example, and to help guide those stuck where I'm stuck, I followed this tutorial (https://firebase.google.com/docs/auth/web/cordova) and created a ~"bare minimum" Cordova app that builds at https://build.phonegap.com. (Maybe it could even be put up on github.com/firebase, as example code, to supplement the tutorial, once it's working?) The built app works great on iOS, but is broken on Android.
Expected behavior (seen on web/iOS):
...."profile02:{"gender":"male", ..."
...."token02: ..."
.... (this means it worked, and it read stuff out of the signin result.)
Not-working behavior (seen on Android):
3-file cordova project attached. (.zip can be uploaded as-is to build.phonegap.com, to replicate above behavior in native apps) Thanks!
firebase-bdemo1.zip
The text was updated successfully, but these errors were encountered: