I have a Flutter app that uses cloud functions. I upgraded one function to a v2 function and it no longer works. The function cannot be found. The function logs do not show that it is being called. It is in the us-central1 region, as is the rest of the project.
final result = await FirebaseFunctions.instance.httpsCallable('addMessage').call();
Instead of addMessage I have tried the full function URL found in the firebase console, but that does not work either.
Function declaration:
exports.addMessage = onCall(async (request) => {
//Run function
});
How do I call a v2 cloud function in flutter?
With cloud_functions version 4.1.0, it is now possible to call 2nd gen cloud functions:
FirebaseFunctions.instance
.httpsCallableFromUrl("https://example.run.app/")
.call({"paramter": "value"});
Note that you need to deploy the function before you can know what the URL will be. This will change in the future according to the docs:
https://cloud.google.com/functions/docs/tutorials/http#triggering_the_function
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With