Skip to content

Documentation

Richard Wei edited this page Jun 13, 2021 · 3 revisions

Welcome to the Aces-Cloud wiki!


Sample implementations of the incrementView Firebase Function

JS

const functions = firebase.functions();
const incrementViews = functions.httpsCallable('incrementView');
incrementViews({ id: 'THE_ID_OF_THE_ARTICLE' }).then((result) => {
   // Read result of the Function.
   const result = result.data.status;
 });

Java

FirebaseFunctions functions = FirebaseFunctions.getInstance();
public Task<String> incrementViews(String articleId) {
    // Create the arguments to the callable function.
    Map<String, Object> data = new HashMap<>();
    data.put("id", articleId);
    
    return functions
            .getHttpsCallable("incrementView")
            .call(data)
            .continueWith(new Continuation<HttpsCallableResult, String>() {
                @Override
                public String then(@NonNull Task<HttpsCallableResult> task) throws Exception {
                    // Get the result (normaly returns {status: "Good"})
                    String result = (String) task.getResult().getData();
                    return result;
                }
            });
}

Swift

lazy var functions = Functions.functions()
functions.httpsCallable("incrementView").call(["id": THE_ID_OF_THE_ARTICLE ]) { (_, _) in }