發表文章

目前顯示的是 10月, 2019的文章

191029 Firebase Task continueWith

這幾天在看 Firebase 的 Call functions from your app https://firebase.google.com/docs/functions/callable 範例中,有一段程式碼如下 return functions .getHttpsCallable( "addNumbers" ) .call(data) .continueWith { task -> // This continuation runs on either success or failure, but if the task // has failed then task.result will throw an Exception which will be // propagated down. val result = task. result ?. data as Map<String, Any> result[ "operationResult" ] as Int }   functions com.google.firebase.functions.FirebaseFunctions https://firebase.google.com/docs/reference/android/com/google/firebase/functions/FirebaseFunctions  .getHttpsCallable( "addNumbers" )   "addNumbers" 為 Cloud Function 的名稱 getHttpsCallable 回傳的是 HttpsCallableReference https://firebase.google.com/docs/reference/android/com/google/firebase/functions/HttpsCallableReference.html .call(data) 傳入的是 addNumbers 可接受的