baasbox - your mobile backend made easy

23
Andrea Tortorella [email protected] +39 06 62 27 54 18 eliantor

Upload: commit-university

Post on 13-Apr-2017

468 views

Category:

Engineering


4 download

TRANSCRIPT

Page 1: BaasBox - Your mobile backend made easy

Andrea Tortorella [email protected]+39 06 62 27 54 18eliantor

Page 2: BaasBox - Your mobile backend made easy

Appsarecomplex

Page 3: BaasBox - Your mobile backend made easy

Greatappdesign

Page 4: BaasBox - Your mobile backend made easy

Appsareconnected

Page 5: BaasBox - Your mobile backend made easy

NoonecaresAboutYour

Backend!

Page 6: BaasBox - Your mobile backend made easy

…YETWITHOUTYOURAPP

ISJUSTATOY

Page 7: BaasBox - Your mobile backend made easy

PutsomeBaasBoxInyourengine

Page 8: BaasBox - Your mobile backend made easy

DEMOTIME

Page 9: BaasBox - Your mobile backend made easy
Page 10: BaasBox - Your mobile backend made easy

AndroidSDK

• SimplifyBaasBox integration• IntegratewithAndroidapis• Favornativebestpractices

Page 11: BaasBox - Your mobile backend made easy

ASHORTGUIDETOTHEAPI

Page 12: BaasBox - Your mobile backend made easy

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

}}});

}

Page 13: BaasBox - Your mobile backend made easy

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

}});

}

Page 14: BaasBox - Your mobile backend made easy

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,...);

Page 15: BaasBox - Your mobile backend made easy

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,...);

Page 16: BaasBox - Your mobile backend made easy

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();

}}

});

Page 17: BaasBox - Your mobile backend made easy

SimpleimagehandlingBaasBox.builder(context)

.addPlugin(GlidePlugin.PLUGIN)

.init();

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

*Effortlessintegrationwithcommonandroidimageloaders

Page 18: BaasBox - Your mobile backend made easy

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

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

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

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

Page 19: BaasBox - Your mobile backend made easy

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");

Page 20: BaasBox - Your mobile backend made easy

ServerpushBaasCloudMessagingService ms = BaasBox.messagingService();

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

BaasCloudMessagingService.DEFAULT_PROFILE,BaasCloudMessagingService.PROFILE2)

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

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

Page 21: BaasBox - Your mobile backend made easy

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) {

//...}

});

Page 22: BaasBox - Your mobile backend made easy

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

Page 23: BaasBox - Your mobile backend made easy

Thank you