BaasBox - Your mobile backend made easy

Preview:

Citation preview

Andrea Tortorella a.tortorella@baasbox.com+39 06 62 27 54 18eliantor

Appsarecomplex

Greatappdesign

Appsareconnected

NoonecaresAboutYour

Backend!

…YETWITHOUTYOURAPP

ISJUSTATOY

PutsomeBaasBoxInyourengine

DEMOTIME

AndroidSDK

• SimplifyBaasBox integration• IntegratewithAndroidapis• Favornativebestpractices

ASHORTGUIDETOTHEAPI

Loginpublic void login(String username,String password) {

BaasUser user = BaasUser.withUserName(username).setPassword(password);

user.login(new BaasHandler<BaasUser>() {@Overridepublic void handle(BaasResult<BaasUser> baasResult) {

if (baasResult.isSuccess()) {//user successfully logged in

}}});

}

Getsomedatapublic void loadDocuments (String collection) {

BaasQuery.Criteria filter = BaasQuery.builder().where("where condition").pagination(0, 3).orderBy("field desc").criteria();

BaasDocument.fetchAll(collection, filter,new BaasHandler<List<BaasDocument>>() {

@Overridepublic void handle(BaasResult<List<BaasDocument>>

baasResult) {//work with the data

}});

}

WorkingwithdocumentsBaasDocument doc = BaasDocument.create("collection");doc.put("key","value");doc.put("key2", JsonArray.of("val1", 2, true));

BaasACL acl = BaasACL.builder().users(Grant.READ, "username1", "username2").roles(Grant.UPDATE, Role.REGISTERED).build();

doc.save(acl,...);

UploadfilesBaasFile file = BaasFile.create();// BaasFile.create(new JsonObject().put("key","metadata"));

byte[] inMemory = ...;file.upload(inMemory,...);

InputStream stream = ...;file.upload(stream,...);

File fileOnDisk = ...;file.upload(fileOnDisk,...);

DownloadfilesBaasFile.fetchStream("id", new BaasHandler<BaasFile>() {

@Overridepublic void handle(BaasResult<BaasFile> baasResult) {

if (baasResult.isSuccess()){BaasFile value = baasResult.value();byte[] fileContent = value.getData();JsonObject serverMeta = value.getMetadata();JsonObject userData =value.getAttachedData();

}}

});

SimpleimagehandlingBaasBox.builder(context)

.addPlugin(GlidePlugin.PLUGIN)

.init();

Glide.with(context).load(file).into(view);

*Effortlessintegrationwithcommonandroidimageloaders

LinkssupportBaasLink.create("relationship","id","target-id",...);

BaasObject source = BaasLink.withId("id").in();

BaasObject target = BaasLink.withId("id").out();

BaasLink.fetchAll(BaasQuery.Criteria.ANY,0,...);

Collaboration/SocialBaasUser.withUserName("wannabe friend").follow(...);

BaasUser.withUserName("my worst enemy").unfollow(...);

BaasUser.current().followers(BaasQuery.builder()

.where("....")

.criteria(),...);

BaasUser.withUserName("a user").following(...);

Role.friendsOf("my friends role");

ServerpushBaasCloudMessagingService ms = BaasBox.messagingService();

ms.newMessage().timeToLive(…).collapseKey(…).profiles(

BaasCloudMessagingService.DEFAULT_PROFILE,BaasCloudMessagingService.PROFILE2)

.extra(JsonObject.of("key","value",

"key2",true)).send(...);

Lowlevelaccess// direct yet simplified restful accessRequestToken token = BaasBox.rest()

.async(httpMethod,"endpoint”,…);

BaasResult<JsonObject> res = BaasBox.rest().sync(httpMethod, "endpoint”,...);

// concurrency and lifecycle control// suspend remote callstoken.suspend();

// resume callstoken.resume(new BaasHandler<JSONObject>() {

@Overridepublic void handle(BaasResult<JSONObject> baasResult) {

//...}

});

G-Ratehttp://www.androidev.it/commit/

Thank you