A backend software, self-hostable and ready to use to power modern apps.
You can access the Kuzzle repository on Github
The complete SDK documentation is available here
Train yourself and your teams to use Kuzzle to maximize its potential and accelerate the development of your projects.
Our teams will be able to meet your needs in terms of expertise and multi-technology support for IoT, mobile/web, backend/frontend, devops.
👉 Get a quote
You can configure your Android project to get Kuzzle's Android SDK from jcenter in your build.gradle:
buildscript {
repositories {
maven {
url "http://dl.bintray.com/kuzzle/maven"
}
jcenter()
}
}
dependencies {
compile 'io.kuzzle:sdk-android:3.0.9'
implementation 'tech.gusavila92:java-android-websocket-client:1.2.2'
}
Kuzzle kuzzle = new Kuzzle("host", new ResponseListener<Void>() {
@Override
public void onSuccess(Void object) {
// Handle success
KuzzleDocument doc = new KuzzleDocument(dataCollection);
doc.setContent("foo", "bar").save();
}
@Override
public void onError(JSONObject error) {
// Handle error
}
});
Options options = new Options();
options.setSsl(true);
Kuzzle kuzzle = new Kuzzle("host", options, new ResponseListener<Void>() {
@Override
public void onSuccess(Void object) {
// Handle success
KuzzleDocument doc = new KuzzleDocument(dataCollection);
doc.setContent("foo", "bar").save();
}
@Override
public void onError(JSONObject error) {
// Handle error
}
});
KuzzleDocument is an encapsulation of a JSONObject.
KuzzleDataCollection myCollection = new KuzzleDataCollection(kuzzle, "myNewCollection");
KuzzleDocument myDocument = new KuzzleDocument(myCollection);
// Add properties to the body
myDocument.setContent("foo", "bar");
// Persist the document
myDocument.save();
// Send it on real time (not persistent)
myDocument.publish();
As stated here you can add metadata to a subscription.
KuzzleOptions options = new KuzzleOptions();
JSONObject metadata = new JSONObject();
metadata.put("foo", "bar");
options.setMetadata(metadata);
myCollection.subscribe(options);
To login using kuzzle you need at least one authentication plugin. You can refer here for a local authentication plugin or here to refer to our OAuth2 plugin.
To know more about how to log in with a Kuzzle SDK, please refer to our documentation
If you have the kuzzle-plugin-auth-passport-local installed you can login using either the Kuzzle's constructor or the login method.
If you have an OAUTH plugin like kuzzle-plugin-auth-passport-oauth, you may use the KuzzleWebViewClient class to handle the second authentication phase:
Handler handler = new Handler();
WebView webView = (WebView) findViewById(R.id.webView);
webView.setWebViewClient(kuzzle.getKuzzleWebViewClient());
kuzzle.login("github", new KuzzleResponseListener<JSONObject>() {
@Override
public void onSuccess(final JSONObject object) {
handler.post(new Runnable() {
@Override
public void run() {
try {
if (object.has("headers")) {
webView.loadUrl(object.getJSONObject("headers").getString("Location"));
}
} catch (JSONException e) {
e.printStackTrace();
}
}
});
}
@Override
public void onError(JSONObject error) {
Log.e("error", error.toString());
}
});