Firebase函数的调用永远不会成功

时间:2019-04-20 13:19:27

标签: android firebase google-cloud-functions

我正在调用Firebase函数中具有的函数,当我尝试获取返回的数据时,该函数永远不会成功。 我正在寻找解决方案,但没有找到,

tornaposicio(12.9, 13.8).addOnCompleteListener(new OnCompleteListener<String[]>() {
    @Override
    public void onComplete(@NonNull Task<String[]> task) {
        if (!task.isSuccessful()) {
            Exception e = task.getException();
            if (e instanceof FirebaseFunctionsException) {
                FirebaseFunctionsException ffe = (FirebaseFunctionsException) e;
                FirebaseFunctionsException.Code code = ffe.getCode();
                Object details = ffe.getDetails();
            }
            i("Task didn't succeed", ".");


        } else {
            i("PARECE QUE FUNCIONA:",".");
            String[] info =  task.getResult();
            i("Task succesfull", info[0]);

        }

    }
});

private Task<String[]> tornaposicio(double latitud, double longitud) {
    // Create the arguments to the callable function.
    HashMap<String, Double> posicio = new HashMap<String, Double>();
    posicio.put("latitud", latitud);
    posicio.put("longitud", longitud);

    return mFunctions
            .getHttpsCallable("tornaposicio")
            .call(posicio)
            .continueWith(new Continuation<HttpsCallableResult, String[]>() {
                @Override
                public String[] then(@NonNull Task<HttpsCallableResult>task) throws Exception {
                    // This continuation runs on either success or failure, but if the task
                    // has failed then getResult() will throw an Exception which will be
                    // propagated down.


                    result = (String[]) task.getResult().getData();


                    return result;

                }
            });

代码总是输入“!task.isSuccessful”,我要相反。

0 个答案:

没有答案