-
Notifications
You must be signed in to change notification settings - Fork 403
/
SolutionDeletes.java
44 lines (38 loc) · 1.48 KB
/
SolutionDeletes.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package com.google.example.firestore;
import androidx.annotation.NonNull;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.firebase.functions.FirebaseFunctions;
import com.google.firebase.functions.HttpsCallableReference;
import com.google.firebase.functions.HttpsCallableResult;
import java.util.HashMap;
import java.util.Map;
public class SolutionDeletes {
// [START call_delete_function]
/**
* Call the 'recursiveDelete' callable function with a path to initiate
* a server-side delete.
*/
public void deleteAtPath(String path) {
Map<String, Object> data = new HashMap<>();
data.put("path", path);
HttpsCallableReference deleteFn =
FirebaseFunctions.getInstance().getHttpsCallable("recursiveDelete");
deleteFn.call(data)
.addOnSuccessListener(new OnSuccessListener<HttpsCallableResult>() {
@Override
public void onSuccess(HttpsCallableResult httpsCallableResult) {
// Delete Success
// ...
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
// Delete failed
// ...
}
});
}
// [END call_delete_function]
}