【发布时间】:2018-10-29 23:22:22
【问题描述】:
我正在尝试从 Android 应用调用异步 Firebase 函数,并在函数返回时收到“INTERNAL”异常。
安卓:
private Task<String> fetchData() {
// Create the arguments to the callable function, which is just one string
Map<String, Object> data = new HashMap<>();
data.put(“id”, “abc”);
return FirebaseFunctions.getInstance()
.getHttpsCallable(“calculate”)
.call(data)
.continueWith(new Continuation<HttpsCallableResult, String>() {
@Override
public String then(@NonNull Task<HttpsCallableResult> task) throws Exception {
Map<String, Object> result = (Map<String, Object>) task.getResult().getData();
return (String)result.get(“data”);
}
});
}
Firebase 功能:
exports.calculate = functions.https.onCall((data, context) => {
const text = data.id;
return calc.calculate( (err, response) => {
if(err) {
// handle error
} else {
const data = response.dataValue;
}
}).then(() => {
return {“data”: data};
});
});
例外:
com.google.firebase.functions.FirebaseFunctionsException: INTERNAL
【问题讨论】:
标签: android firebase asynchronous google-cloud-functions