The version 16.1.0 of the Cloud Functions Client SDK now allows us to test against a local instance of the Cloud Functions Emulator by using useFunctionsEmulator().
It would be nice to have a snippet showing this method's usage and maybe also include a link pointing to the Functions Emulator Docs.
@rosariopfernandes thanks for the suggestion! This is definitely something we should do.
For new visitors I put this into work:
FirebaseFunctions.getInstance().useFunctionsEmulator("http://192.168.1.30:5000")
FirebaseFunctions.getInstance()
.getHttpsCallable("helloWorld")
.call()
.addOnCompleteListener { result -> }
And remember to make the firebase server accessible:
firebase serve --only functions
to
firebase serve --only functions --host 0.0.0.0
Any updates on this?
How to get logs? 馃摝
@jQrgen we have some docs on this here:
https://firebase.google.com/docs/emulator-suite/connect_and_prototype?database=Firestore#instrument_your_app_to_talk_to_the_emulators
Basically you want to start the functions emulator like this:
firebase emulators:start --only functions
And then in your Android app (on the same machine):
FirebaseFunctions.getInstance().useFunctionsEmulator("http://10.0.2.2:5001");
Of course this is an http endpoint not https so for apps targeting Android 8.0+ the platform will block this by default.
The simplest solution is to change this globally in your debug builds:
<application
android:usesCleartextTraffic="true"
However if you're concerned about security you can set a more advanced per-host network security file:
https://developer.android.com/training/articles/security-config
Thanks! works now
Most helpful comment
For new visitors I put this into work:
And remember to make the firebase server accessible:
firebase serve --only functionsto
firebase serve --only functions --host 0.0.0.0