skip to Main Content

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.

2

Answers


  1. Do you use Capacitor HTTP to patch fetch and XHR requests? that might be the issue.. check if you have the following block in your capacitor.config.ts file plugins section

    CapacitorHttp: {
      enabled: true,
    },
    

    if yes, remove it and try. When capacitor is patching the Firebase XHR request its casuing some issue which returns error. Same is discussed in the Thread Here

    Login or Signup to reply.
  2. it is fixed in the latest angular-fire version,
    you can use it and this will solve the issue

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search