Skip to content
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

Cordova - Google and Facebook sign in do not redirect back to app in IOS #365

Open
rb010 opened this issue Apr 8, 2018 · 24 comments
Open
Assignees

Comments

@rb010
Copy link

rb010 commented Apr 8, 2018

I am working with Ionic and Firebaseui. I have followed the example at https://github.com/alexnu/IonicFirebaseUI and I have made the configurations according to https://firebase.google.com/docs/auth/web/cordova.

It works perfectly with Android, but not with IOS.

After sign in with Google or Facebook, it redirects to localhost:8080/var/containers/Bundle/Application/FDAD4E7B-4917-95FA-409157167EEB/appname.app/www/index.html in Safari and shows the message: “Safari cannot open the page because it could not connect to the server”.

I have tried to downgrade to UIWebView, by adding to config.xml:

But, when I do this, if I click the Google or Facebook login button, it shows “This operation is not supported in the environment this application is running on. "location.protocol" must be http, https or chrome-extension and web storage must be enabled.”

Ionic: 3.20.0
Firebase: 4.12.1
Firebaseui: 2.7.0

@bojeil-google
Copy link
Contributor

This is related to the new version of Ionic which in iOS uses WKWebview with localhost. It is a known issue. You have to downgrade to an older version for now until this is fixed.
In the meantime you need to confirm in the older version you are using that the URL is file URL and that deviceready is getting triggered (also make sure all the plugins required are installed).

@cmartin81
Copy link

Are there any timeline on this issue?

@cmartin81
Copy link

cmartin81 commented Apr 10, 2018

Add this to your config:
<preference name="CordovaWebViewEngine" value="CDVUIWebViewEngine" />

Source:
https://stackoverflow.com/questions/48314299/firebase-social-login-not-redirected-to-the-app-ionic-3-ios

It worked for me

@rb010
Copy link
Author

rb010 commented Apr 10, 2018

If I add this to my config, when I try to sign in I get the message “This operation is not supported in the environment this application is running on. "location.protocol" must be http, https or chrome-extension and web storage must be enabled.”

@jalajc
Copy link

jalajc commented Apr 10, 2018 via email

@bnfrnz
Copy link

bnfrnz commented Jul 13, 2018

Hi @bojeil-google! Since this issue is still open, is it fair to assume that for the auth UI to work we'd still need to downgrade to CDVUIWebViewEngine ?

And if so, do you know if this is this something that can/will be addressed by the Firebase team? Any timeline maybe?

I'm just asking because then we may adjust our plans and postpone the implementation of additional auth options for now. The CDVWKWebViewEngine is noticeably faster and we'd probably rather wait than downgrading to CDVUIWebViewEngine . Would be great if you had any info to help us deciding. Thanks!

@bojeil-google
Copy link
Contributor

The Firebase Auth team would still like to fix this issue. The problem is that it is a sensitive change to fix as it could have unintended consequences. The problem is not the webviewengine but the fact that a local server is spun in the process. If I understand this correctly, the page is getting served as http://localhost instead of the typical file:// environment.

@bnfrnz
Copy link

bnfrnz commented Jul 14, 2018

Thanks for the prompt response. OK, that sounds a bit more complex.

Is my understanding correct though that this means deeplinking into an Ionic app (with WKWebView) is generally an issue then, irrespective of Firebase Auth? Because if so, I might try to bring this up with the Ionic team instead.

Deeplinking is getting very important for invites/user acquisitions etc. and if that didn't work, it'd be a serious shortcoming of Ionic...

@bojeil-google
Copy link
Contributor

I don't think the deep linking is the problem. For Firebase Auth, it gets tricky (http://localhost) to tell apart what environment this is running, a typical browser environment or a mobile cordova/ionic environment without adding some expensive delays. I believe the deep linking should still be detectable.

Though, I think having a native way for handling deep linking in Cordova would be a huge asset to all Cordova/Ionic developers. I am not sure if this is something they would provide as a built-in API.

@bnfrnz
Copy link

bnfrnz commented Jul 23, 2018

Thanks for getting back. We've postponed email+password login for now but would definitely use FirebaseUI in the future if there's a way to work with WKWebView and #21.

Thanks again for being so responsive!

@corysmc
Copy link

corysmc commented Nov 1, 2018

This is related to the new version of Ionic which in iOS uses WKWebview with localhost. It is a known issue.

@bojeil-google can you provide a link to the known issue? I've been trying to find the right issue to follow

@ericgopak
Copy link

ericgopak commented Dec 1, 2018

I had the same issue, and changing the webview engine didn't solve it for me.

What worked for me was to add <allow-navigation href="http://*" /> to config.xml.

I guess this worked for me because localhost:8080 works over http, but I only had https://* allowed in my config.xml.

@MSchmack
Copy link

MSchmack commented Dec 2, 2018

This is related to the new version of Ionic which in iOS uses WKWebview with localhost. It is a known issue.

@bojeil-google can you provide a link to the known issue? I've been trying to find the right issue to follow

firebase/firebase-js-sdk#1244

@emgie123
Copy link

Not only ios issue, on android same problem

@RezaRahmati
Copy link

<allow-navigation href="http://*" /> doesn't work for me

@pedrovitor074
Copy link

any new?

@chelopme
Copy link

Same issue over here, only on IOS. Moving away from firebase auth, at least for now

@ldupisani
Copy link

Same issue here, but on Android.

Tried downgrading to [email protected] , but no luck on that either. It tries redirecting back to localhost:8100 in chrome, which obviously doesn't exist.

Tried:
On both webview version, didn't help.

@imThamizhselvan
Copy link

yes it exists in android too

@MatthewPringle
Copy link

I have had the same issue, on iOS 12 at least of it never redirecting back to the app successfully.

Instead it eventually ends up at about:blank and the browser tab doesn't close.

It seems that the app goes to sleep when the sign in window is opened and isn't running when the callback is passed.

To solve this I installed https://github.com/katzer/cordova-plugin-background-mode and set it to keep the app awake in the background using cordova.plugins.backgroundMode.enable()

I plan to just enable and disable as needed but can anyone else check if it solves their problem.

@RohanTalip
Copy link

To solve this I installed https://github.com/katzer/cordova-plugin-background-mode and set it to keep the app awake in the background using cordova.plugins.backgroundMode.enable()

I can't thank you enough @MatthewPringle!!

Actually, all I needed to do was to install cordova-plugin-background-mode and the Google sign in redirected back to my app in iOS (previously it would get stuck at an about:blank page, due to needing to use cordova-plugin-wkwebview-engine to fix layout issues ... the user could press on the Done button in the top left but it wasn't a good experience at all).

I plan to just enable and disable as needed but can anyone else check if it solves their problem.

I found that even just installing the plugin and leaving it (by default) disabled solved my problem. Odd but true. I'm not sure what the plugin is doing that is fixing things for me, but I'll take the win.

Now to see if this change to my app will get approved by Apple ...

@RohanTalip
Copy link

Actually, this doesn't work for the situation where I get a prompt via the Gmail app for verifying the sign-in event, i.e. I'm switching to the Gmail app which means my app gets backgrounded temporarily. Switching back to my app after the verification in the Gmail app, I see that I still eventually get to the about:blank page.

Specifying cordova.plugins.backgroundMode.enable() before the FirebaseUI screen is shown (and disabling it after a successful login) didn't seem to work either.

Time to debug this or find a different solution ...

@saoud77
Copy link

saoud77 commented Oct 12, 2019

It worked with me when I downgrade ios platform to 4.5.4

First: you need to remove the current ios platform:
cordova platform rm ios

Second: add ios platform version 4.5.4
cordova platform add [email protected]

@louisameline
Copy link

Starting from April 2020 (this month!), Apple will no longer accept hybrid apps that do not use WKWebView.
As others, I made the switch from the UIWebView.
Only to realize that the regular Cordova WKWebView has bugs that the Ionic webview fixes, plus improvements.
So, now would be a great time to decide if something can be done or not, so we can take an appropriate decision. Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests