Hook android client
#About
This is a port of the JavaScript client. The library is a native Android Library, with no external dependencies, targetting Android API Level 10. It doesn't require the JavaScript client either, the library communicates with hook's REST interface.
#How to Use
String appId = "1";
String appKey = "q1uU7tFtXnLad6FIGGn2cB+gxcx64/uPoDhqe2Zn5AE=";
String endpointURL = "http://hook.ddll.co";
Context context = this;
Client client = new Client(context, endpointURL, appKey, appId);
JSONObject data = new JSONObject();
data.put("device", "Samsung Galaxy");
data.put("version", 10.0);
data.put("hasCameraSupport", true);
client.collection("android").create(data, new Responder() {
@Override
public void onSuccess(Response response) {
Log.d("hook", response.raw);
/*
Response object:
public JSONObject object;
public JSONArray array;
public String raw;
public int code;
*/
}
@Override
public void onError(Response response) {
Log.d("hook", "onError: "+response.raw);
}
});
client.collection("android").where("version", 10).get(new Responder() {
@Override
public void onSuccess(Response response) {
Log.d("hook", response.object.optString("version"));
}
@Override
public void onError(Response response) {
Log.d("hook", "onError: "+response.raw);
}
});
sort
where
limit
offset
increment
decrement
avg
max
min
sum
- See Collection.java for better reference
JSONObject data = new JSONObject();
data.put("email", "[email protected]");
data.put("name", "Gabriel Laet");
data.put("password", "123");
client.auth.authenticate(Auth.PROVIDER_EMAIL, data, responder);
Once the user is created, you don't need to verify/login again. The library also takes care to store the current user internally.
JSONObject data = new JSONObject();
data.put("accessToken", "asdasdasd12341243123");
data.put("userID", "21313");
client.auth.authenticate(Auth.PROVIDER_FACEBOOK, data, responder);
JSONObject data = new JSONObject();
data.put("email", "[email protected]");
data.put("password", "123");
client.auth.verify(Auth.PROVIDER_EMAIL, data, responder);
forgotPassword
resetPassword
logout
getAuthToken
hasAuthToken
- See Auth.java for better reference