I'm trying to calling a firebase cloud function that I have written.
I have tested the function using Postman to mimic HTTP requests. Here is the JSON result when I call my function within Postman:
{
"groups": [
{
"isPublic": true,
"members": [
true
],
"numberOfMembers": 1,
"groupId": "-LAOPAzMGzOd9qULPxue"
},
{
"isPublic": true,
"members": [
true
],
"numberOfMembers": 1,
"groupId": "-LAOP7ISDI2JPzAgTYGi"
}
]
}
I am attempting to do the same and retrieve this JSON list within my android app. I am following the example on Firebase's website :https://firebase.google.com/docs/functions/callable
This is Firebase's example on how to retrieve the data:
return mFunctions
.getHttpsCallable("addMessage")
.call(data)
.continueWith(new Continuation<HttpsCallableResult, String>() {
@Override
public String then(@NonNull Task<HttpsCallableResult> task) throws Exception {
String result = (String) task.getResult().getData();
return result;
}
});
It is unclear how I can take the result from my cloud function and use it in the rest of my Android app.
Furthermore, this example returns a Task object which according to Firebase's documentation has now deprecated : https://firebase.google.com/docs/reference/admin/java/reference/com/google/firebase/tasks/Task)
Is there a clearer, more simple way to handle the data from a function call?
Calling a function is extremely simple so I feel that there must be a more straight forward method to receiving the response.
getValue
ortoObject
which automatically generate model object from retrieved snapshop in RTDB and Firestore. It seemstask.getResult().getData()
returns anObject
. Does it means it can also be String, Integer, List or something else?