capawesome-team / capacitor-firebase

⚡️ Firebase plugins for Capacitor. Supports Android, iOS and the Web.
https://capawesome.io/plugins/firebase/
Apache License 2.0
382 stars 99 forks source link

bug(functions): callByUrl does not work on Android #672

Closed mamillastre closed 2 months ago

mamillastre commented 2 months ago

Plugin(s)

Version

6.1.0

Platform(s)

Current behavior

The callByUrl() method call the function using a function name. So the current request is: https://us-central1-<projectId>.cloudfunctions.net/https://my-provided-url.com/...

Expected behavior

The correct request must be made.

To fix it: In the FirebaseFunctions.java file line 44:

- .getHttpsCallable(url)
+ .getHttpsCallableFromUrl(url)

Reproduction

https://github.com/capawesome-team/capacitor-firebase

Steps to reproduce

Sorry, I did not provide a reproduction repo.

To reproduce, you must call a function using an URL on Android:

const { data } = await FirebaseFunctions.callByUrl({
    url: 'https://us-central1-YOUR_PROJECT_ID.cloudfunctions.net/helloWorld'
});

With the current bug, the call will be: https://us-central1-YOUR_PROJECT_ID.cloudfunctions.net/https://us-central1-YOUR_PROJECT_ID.cloudfunctions.net/helloWorld So it's returns 404.

Other information

This method works on the web and I did not test it on iOS but the code looks ok.

Capacitor doctor

@capacitor/cli: 6.1.0 @capacitor/android: 6.1.0 @capacitor/core: 6.1.0

Before submitting

robingenz commented 2 months ago

Would you be willing to create a PR again?

mamillastre commented 2 months ago

ok I will do that quickly