O slideshow foi denunciado.
Utilizamos seu perfil e dados de atividades no LinkedIn para personalizar e exibir anúncios mais relevantes. Altere suas preferências de anúncios quando desejar.

Parse: A Mobile Backend as a Service (MBaaS)

785 visualizações

Publicada em

Parse is a mobile backend as a service (MBaaS), a subcategory of PaaS. This is a presentation evaluating the service for a post-graduate seminar course.

Publicada em: Software
  • Entre para ver os comentários

Parse: A Mobile Backend as a Service (MBaaS)

  1. 1. PARSE BACKEND AS A SERVICE Ville Seppänen
  2. 2. CONTENTS Whatis Parse? Parse Data&Parse Push Android Demo Other services: Cloud code, Social, Analytics Evaluation &Summary
  3. 3. WHAT IS PARSE?
  4. 4. PARSE IS A MBAAS Parse is ahosted closed-source, proprietarymobile-backend-as- a-service (mBaaS) Itoffers BaaS over APIs for severalplatforms
  5. 5. SERVICE CATALOGUE Parse Database Parse Push notifications Parse User managementand Socialweb integration Cloud Code server-side code hosting Parse Analytics
  6. 6. SUPPORTS MOST PLATFORMS Mainplatforms: Android, iOS, OS X, JavaScript, Windows 8, Windows Phone 8, Unity, REST 3rd partylibraries: .NET, Java, Clojure, jQuery, Node, PHP, Python, Objective-C, Qt, Ruby, ...
  7. 7. OWNED BY FACEBOOK April2013: "Facebook boughtmobile cloud services company Parse for areported $85 million" readwrite.com/2013/04/29/parse-acquisition-makes-its- rivals-very-happy Even when you are notin Facebook, you are partof Facebook?
  9. 9. PARSE RUNS ON AMAZON WEB SERVICES aws.amazon.com/solutions/case-studies/parse
  10. 10. PARSE SUPPORT GettingStarted guides, Tutorials and API documentation StackOverflow (843 parse.com questions) Parse's own "StackOverflow clone" Parse Developer Dayconference held in September 2013 parse.com/help
  11. 11. APP BASICS Asingle Parse developer accountcan hold manyApps, paying customers can collaborate on an app Apps are isolated from each other Dashboard for simple managementand monitoring
  12. 12. DASHBOARD
  13. 13. PARSE DATA
  14. 14. EFFORTLESS DATABASE JSON-based, auto-generated schema, semi-relational notreal-time, notauto-syncing(started makingachatapp around the db untilI realized this) AParse devsuggested creatingsync with push notifications ParseObjects can onlybe 128kb, ParseFile objectcan be 10 megabytes parse.com/questions/real-time-updates-like-firebase
  15. 15. SMALLEST WORKING EXAMPLE //InitParseandauto-generateananonymoususerforthisinstallation Parse.initialize(this,YOUR_APPLICATION_ID,YOUR_CLIENT_KEY); ParseUser.enableAutomaticUser(); //UploadanewobjecttotheParsedatabase ParseObjectgameScore=newParseObject("GameScore"); gameScore.put("score",1337); gameScore.put("playerName","SeanPlott"); gameScore.saveInBackground();
  16. 16. SUBCLASSING PARSEOBJECT Instead of: ParseObjectshield=newParseObject("Armor"); shield.put("displayName","WoodenShield"); shield.put("fireproof",false); We can have: Armorshield=newArmor(); shield.setDisplayName("WoodenShield"); shield.setFireproof(false); @ParseClassName("Armor") publicclassArmorextendsParseObject{/*...*/} ParseObject.registerSubclass(Armor.class);
  19. 19. REST CALLS curl--requestGET --header"X-Parse-Application-Id:Xlsvm0...WL4in" --header"X-Parse-REST-API-Key:0OPlRuE...5lk" --get --data-urlencode'where={"playerName":"SeanPlott","cheatMode":false}' https://api.parse.com/1/classes/GameScore { "results":[ { "playerName":"SeanPlott", "updatedAt":"2011-08-21T18:02:52.248Z", "cheatMode":false, "createdAt":"2011-08-20T02:06:57.931Z", "objectId":"Ed1nuqPvcm", "score":73453 } ] }
  20. 20. ACCESS CONTROL LISTS (ACL) Each objecthas its own ACL of users/roles/everyone and their read/write access rights { "*":{ "read":true }, "F4ori0jU9r":{ "write":true, "read":true } }
  21. 21. CLASS-SPECIFIC ACCESS CONTROL Get: fetchingan objectbyits objectId. Find: issuingaqueryto fetch objects. Update: savingan objectthatalreadyexists and has been modified. Create: savingan objectthatis new and hasn'tbeen created yet. Delete: deletingan object. Add fields: addingfields to the class.
  22. 22. ROLE-BASED ACCESS CONTROL Users can be grouped into roles Subroles can be grouped into roles Roles can be referred to in ACLs //Createnewroleobject ParseACLroleACL=newParseACL(); roleACL.setPublicReadAccess(true); ParseRolerole=newParseRole("Administrator",roleACL); //Adduserandchildroletorole role.getUsers().add(newUser); role.getRoles().add(childRole); role.saveInBackground();
  23. 23. PARSE PUSH
  25. 25. PUSH NOTIFICATIONS Parse offers scheduling, expiration time and targetsegmenting Can be sentfrom the dashboard and from allSDKs, butonly received in iOS, Android and Win8 "Metro" Requires Apple Push Certificate on iOS and Windows Push Credentials on Win8 apps. On Android Parse has its own service, with pros and cons
  26. 26. CUSTOMIZING PUSH NOTIFICATIONS alert: the notification's message. badge: (iOS only) the value indicated in the top rightcorner of the app icon. This can be setto avalue or to Incrementin order to incrementthe currentvalue by1. sound: (iOS only) the name of asound file in the application bundle. content-available: (iOS only) if you are usingNewsstand, set this value to 1 to trigger abackground download (more here). action: (Android only) the Intentshould be fired when the push is received. If nottitle or alertvalues are specified, the Intent willbe fired butno notification willappear to the user. title: (Android only) the value displayed in the Android system traynotification.
  27. 27. PUSH CHANNELS Installations (notusers) subscribe to pushes
  28. 28. JAVASCRIPT PUSH Send push message Parse.initialize("RNh7...vfJtTC","1CdI01...21iU"); varrecent=newDate(newDate().getTime()-(24*3600*1000)); varquery=newParse.Query(Parse.Installation); query.equalTo('channels','Control'); query.greaterThanOrEqualTo("updatedAt",recent); Parse.Push.send({ where:query, data:{ alert:"HelloJavaScript!" } },{ success:function(){/*Pushwassuccessful*/}, error:function(error){/*Handleerror*/} });
  29. 29. JSON DATA PUSH { "title":"BaasChat", "alert":"Hellomobileclient!", "myCustomData":"foobar" }
  30. 30. EXECUTE (ANDROID) CLIENT CODE VIA PUSH { "action":"fi.vilsepi.peekaboo.TAKE_PHOTO", "sneakyPayload":"anyparametersforourfunctioncall" } <!--thefunctiononReceive(context,intent)ofthisclasswillbecalled--> <receiverandroid:name="fi.vilsepi.peekaboo.BackgroundPushReceiver"> <intent-filter> <actionandroid:name="fi.vilsepi.peekaboo.TAKE_PHOTO"></action> </intent-filter> </receiver> UiPushReceiverpushReceiver=newUiPushReceiver(newHandler()); registerReceiver(pushReceiver,newIntentFilter("fi.vilsepi.peekaboo.PHOTO_TAKEN")); publicclassUiPushReceiverextendsBroadcastReceiver{ publicvoidonReceive(finalContextcontext,Intentintent){ Stringaction=intent.getAction(); Stringchannel=intent.getExtras().getString("com.parse.Channel"); JSONObjectjson=newJSONObject(intent.getExtras().getString("com.parse.Data")); //etc.. } }
  31. 31. UNDER THE HOOD On Android, pushes use Parse's own background service Pushes are cleartextHTTP over open TCP connection from push.parse.com { "time":"2013-10-17T12:33:00.224Z", "oauth_key":"RNh7DvetGOeZtifApJ2yTUrVg9wY0rq4ULvfJtTC", "data":{ "alert":"HelloWireshark!", "push_hash":"3616ff34c02d2e63b895ec112765f270" } }
  32. 32. DEMO TIME!
  33. 33. ANDROID DEMO 1. Enable Settings -> Security-> Unknown sources 2. Installvilsepi.dyndns.org/baas (testedonGingerbread2.3.3,JellyBean4.2and4.3)
  34. 34. PEEKABOO: CAMERA SHARING APP vilsepi.dyndns.org/baas
  35. 35. JAVASCRIPT CLIENT Latestphotos from allusers
  36. 36. HOW IT WORKS 1. on firststart, auto-generate an anonymous user 2. update the user into the database and subscribe to push channels 3. queryfor users thathave been modified lately, pick one at random 4. send clientpush to the targetviaParse 5. on receivingTAKE_PHOTO, take aphoto with cameraand upload itto Parse 6. once photo has been uploaded, send clientpush to requester viaParse 7. on receivingPHOTO_TAKEN, queryfor Photos thatcurrent user has requested
  38. 38. CLOUD CODE: HOSTED SERVER-SIDE CODE server-side Javascriptprograms code is uploaded to Parse usingCLI tool(simple as "parse deploy")
  39. 39. BAASBLOG.PARSEAPP.COM Vilperi Demo blog for BaaS seminar http://fi.lipsum.com/October 22nd 2013, 12:20 pm Lorem Ipsum on yksinkertaisesti testausteksti, jota tulostus- ja ladontateollisuudet käyttävät. Lorem Ipsum on ollut teollisuuden normaali testausteksti jo 1500-luvulta asti, jolloin tuntematon tulostaja otti kaljuunan... baasblog.parseapp.com/posts/new username: baas password: baas
  40. 40. NOT JUST WEB APPS Clientapps can make function calls to server-side code Cloud code can run scheduled jobs JS modules for 3rd partyservices: photochecking, email, credit cards, sms, voice calls parse.com/docs/cloud_code_guide#functions
  41. 41. CLOUD CODE LIMITS Functions have stricttime limits (15 seconds, 3 seconds for beforeSave and afterSave) Background jobs are killed in 15 minutes Onlyone job runningatatime (payfor whoppingtwo jobs), restare queued This is notacomputation IaaS butrather cleaningup the data thatis stored
  42. 42. OTHER CLIENT SDK FEATURES Socialand identityintegration with Facebook and Twitter Convinience methods for adaptingdataqueries into UI elements Geolocation helper functions Cachingdatain clientdevices (saveEventually, saveInBackground...) Analytics, custom metrics (errors, user behavior)
  43. 43. SUMMARY
  44. 44. EVALUATION database is not"real-time"and auto-syncinglike Firebase datacan be exported easily, butcode is specific to the proprietaryAPI
  45. 45. Varyingdelayin push notifications Sometimes often the Android client's push service dies silently CloudCode snippetfor Google Cloud Messaging parse.com/questions/ios-push-notifications-very-unreliable citrrus.com/blog/what-going-on-with-parse-dot-com parse.com/questions/gcm-support
  46. 46. cannotchange/resetAPI keys cannoteasilycopy/fork/clone an app can onlyview push statistics in the dashboard
  47. 47. WHAT PARSE IS GOOD FOR backend for (multi-plaform) mobile apps push notifications for marketingand user engagement probablynotthe bestoption if you onlyneed adatabase
  48. 48. QUESTIONS? dafuqdidijustwatch?
  49. 49. THANK YOU!