firebase local emulation side:
initialize_app()
@https_fn.on_call( cors=options.CorsOptions(
cors_origins="*",
cors_methods=["get", "post", "options"],))
def validateEmail(req: https_fn.CallableRequest) -> Any :
return {"text":{"valid:":"true"}}
The android app side.
val func = Firebase.functions
private fun validateEmail(str:String): Task<String> {
val data = hashMapOf(
"email" to str
)
return func.getHttpsCallable("validateEmail").call(data)
.continueWith()
{ task ->
println("RAM_DBG" + task.result?.data.toString())
task.result?.data as String
}
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
func.useEmulator("localhost", 5001)
validateEmail("[email protected]")
.addOnCompleteListener { task ->
if (!task.isSuccessful)
{
val e = task.exception
if(e is FirebaseFunctionsException)
{
println("RAM_DBG:" + e.code.toString() + e.details.toString())
}
}
}
This alwasy gives the FirebaseFunctionsException and code = INTERNAL. what is wrong?
What instrumentation and logging possibilites are there on both sides?
When running using curl like below
curl -H "Content-Type:application/json" -d @book.json -X POST http://127.0.0.1:5001/<app>/us-central1/validateEmail
{"result":{"text":{"valid":"true"}}}
Expecting the "valid:":"true" to be returned
2
Answers
The key "valid:" might cause issues because of the colon. Change it to "valid"
This isn’t right:
In the Android emulator, "localhost" refers to the Android emulator virtual machine itself, which is not where your Firebase emulator is running. Your emulator is running on your development machine, which is referred to as 10.0.2.2 from within in the Android emulator. See the Android documentation for details:
See also the Firebase emulator documentation:
See also: