Firebase Cloud Storage 'getDownloadUrl' Not Working With Ionic 'capacitor://localhost' iOS

Operating System

iOS 16.5

Browser Version

Capacitor iOS WebView

Firebase SDK Version

9

Firebase SDK Product:

Storage

Describe your project’s tooling

Ionic Angular Capacitor

Describe the problem

No output for getDownloadUrl when served from capacitor://localhost (native app) when running command ‘ionic cap build ios’ and running the project from Xcode but works from http://localhost when running command 'ionic cap run ios -l --external --open ’

I tried using then/catch and tried try/catch with no hope, and checked the source code of the library and seems the lib doesn’t through an error if there. I tried to edit the lib from node_modules but with the build process of tree shaking, minification, uglification, and removing console.logs() that was super hard. I know that Google mustn’t support strange protocols like capacitor://localhost but that how 30% of the market apps uses right now, can I get little help please what is going wrong? maybe some whitelisting maybe some storage permissions? I spent 10 hours straight debugging this, but with no good news…

Steps and code to reproduce issue

in ‘http://localhost

getDownloadURL(storageRef)
          .then((res) => {
            console.log(res); //working
          })
          .catch((err) => {
            console.log(err); //no output
          });

in ‘capacitor://localhost’

getDownloadURL(storageRef)
          .then((res) => {
            console.log(res); //no output
          })
          .catch((err) => {
            console.log(err); //no output
          });

Your help is appreciated.

Sadly some javascript libraries still don’t work when not using http/https schemes.
You should report the issue to google as only they can fix it.
You’ll have to use a plugin that uses the native sdk, such as GitHub - BazuMax/capacitor-firebase-storage (I have not tried it, so not sure if it works)

Are you saying that the firebase function does not work on device? Or are you changing the url in capacitor config? And if so why?

I have use getdownloadurl multiple times with ionic capacitor, on device with no problems. There is no need for an additional plugin IMHO.

Please provide additional information.