I have tried to create an function in europe-central2 region. Unfortunately, I got this error if the function is not in the default region when calling from the Kotlin sdk:
return Firebase.functions.httpsCallable("returnDistricts").invoke().data<String>()
FATAL EXCEPTION: main
Process: com.app.afterfood.android, PID: 6689
com.google.firebase.functions.FirebaseFunctionsException: NOT_FOUND at com.google.firebase.functions.FirebaseFunctions$2.onResponse(FirebaseFunctions.java:388)
It works perfect if it is in default region: us-central1.
Any idea if it is possible to call a function that is not in the default region?
This is covered in the documentation:
Note: To call a function running in any location other than the default us-central1, you must set the appropriate value at initialization. For example, on Android you would initialize with
getInstance(FirebaseApp app, String region)
.
This means you will need to need to get a FirebaseFunctions instance using getInstance, passing the region to use for that FirebaseApp instance in the second paramter.
Firebase.functions
.getInstance(/* your region params */)
.httpsCallable(...)