public class AVCloud extends Object
The AVCloud class defines provides methods for interacting with AVOSCloud Cloud Functions. A Cloud Function can be called with AVCloud.callFunctionInBackground(String, Map, FunctionCallback) using a FunctionCallback. For example, this sample code calls the "validateGame" Cloud Function and calls processResponse if the call succeeded and handleError if it failed.
AVCloud.callFunctionInBackground("validateGame", parameters, new FunctionCallback() {
public void done(Object object, AVException e) {
if (e == null) {
processResponse(object);
} else {
handleError();
}
}
}
Using the callback methods is usually preferred because the network operation will not block the calling thread. However, in some cases it may be easier to use the * AVCloud.callFunction(String, Map) call which do block the calling thread. For example, if your application has already spawned a background task to perform work, that background task could use the blocking calls and avoid the code complexity of callbacks.
| Constructor and Description |
|---|
AVCloud() |
| Modifier and Type | Method and Description |
|---|---|
static <T> T |
callFunction(String name,
Map<String,?> params)
Calls a cloud function.
|
static <T> void |
callFunctionInBackground(String name,
Map<String,?> params,
FunctionCallback<T> callback)
Calls a cloud function in the background.
|
static Object |
convertCloudResponse(String response) |
static <T> T |
rpcFunction(String name,
Object params)
Calls a cloud function as rpc call in the background.
|
static <T> void |
rpcFunctionInBackground(String name,
Object params,
FunctionCallback<T> callback)
Calls a cloud function as rpc call in the background.
|
static void |
setProductionMode(boolean productionMode)
设置调用云代码函数的测试环境或者生产环境,默认为true,也就是生产环境。
|
public static void setProductionMode(boolean productionMode)
productionMode - 是否是生产环境public static <T> T callFunction(String name, Map<String,?> params) throws AVException
T - return type of cloud functionname - The cloud function to callparams - The parameters to send to the cloud function. This map can contain anything that
could be placed in a AVObject except for AVObjects themselves.AVException - cloud function call exceptionpublic static <T> void callFunctionInBackground(String name, Map<String,?> params, FunctionCallback<T> callback)
T - return type of cloud functionname - The cloud function to callparams - The parameters to send to the cloud function. This map can contain anything that
could be placed in a AVObject except for AVObjects themselves.callback - The callback that will be called when the cloud function has returned.public static <T> void rpcFunctionInBackground(String name, Object params, FunctionCallback<T> callback)
T - return type of cloud functionname - function nameparams - function paramscallback - callback The callback that will be called when the cloud function has returned.public static <T> T rpcFunction(String name, Object params) throws AVException
T - return type of cloud functionname - function nameparams - function paramsAVException - cloud function exceptionCopyright © 2017. All rights reserved.