Lesson 6:
Accessing	
  REST	
  and	
  Backend	
  as	
  a	
  
Service	
  (BaaS)	
  Cloud	
  Services	
  
Jim	
  McKeeth	
  ...
Mobile	
  App	
  Development	
  
▪  Lesson	
  1	
  –	
  Hello	
  World!	
  My	
  First	
  Multi-­‐Device	
  App	
  
▪  Les...
Lesson	
  6	
  Agenda	
  
▪  REST	
  Client	
  Library	
  
▪  REST	
  Debugger	
  
▪  Backend	
  as	
  a	
  Service	
  (Ba...
REST	
  Client	
  Library	
  
▪  Framework	
  for	
  accessing	
  REST-­‐based	
  web	
  services	
  
▪  The	
  framework	...
REST	
  Client	
  Library	
  Components	
  
▪  TRESTClient	
  -­‐	
  manages	
  the	
  HTTP	
  connection	
  to	
  the	
  ...
REST	
  Debugger	
  
▪  Included	
  on	
  the	
  Tools	
  Menu	
  
▪  Use	
  it	
  to	
  making	
  queries	
  to	
  test	
...
Cloud	
  Service	
  (BaaS)	
  Integration	
  
▪  Use	
  push	
  notifications	
  to	
  engage	
  your	
  users	
  
▪  Acces...
BaaS	
  =	
  Backend	
  as	
  a	
  Service	
  
▪  Most	
  mobile	
  apps	
  need	
  server	
  storage	
  for	
  data,	
  i...
Backend-­‐as-­‐a-­‐Service	
  Client	
  Components	
  
▪  Based	
  on	
  REST	
  Client	
  architecture	
  that	
  
was	
 ...
Backend-­‐as-­‐a-­‐Service	
  Model	
  
▪  Supports	
  abstract	
  features,	
  provider	
  independent	
  
–  Create,	
  ...
Push	
  Notifications	
  Scenarios	
  
▪  Send	
  reminders	
  to	
  mobile	
  apps	
  even	
  when	
  not	
  active	
  
–...
REST	
  and	
  BaaS	
  Samples	
  
▪  REST	
  and	
  BaaS	
  mobile	
  samples	
  
–  REST	
  –	
  SurfSpotFinder	
  
–  B...
REST	
  and	
  BaaS	
  Demos	
  
Next	
  Steps	
  for	
  our	
  Business	
  Mobile	
  App	
  
▪  Use	
  the	
  REST	
  Client	
  Library	
  components	
  t...
Lesson	
  6	
  Review	
  
▪  Quickly	
  use	
  REST	
  Services	
  using	
  REST/JSON	
  and	
  the	
  REST	
  client	
  l...
Resources	
  (1	
  of	
  4)	
  
▪  REST	
  Client	
  Library	
  -­‐	
  Docwiki	
  
–  http://docwiki.appmethod.com/appmeth...
Resources	
  (2	
  of	
  4)	
  
▪  BaaS	
  –	
  DocWiki	
  
–  http://docwiki.appmethod.com/appmethod/1.14/libraries/en/RE...
Resources	
  (3	
  of	
  4)	
  
▪  Videos	
  on	
  Demand	
  
–  David	
  I	
  “BaaS	
  webinar”	
  replay	
  
▪  http://w...
Resources	
  (4	
  of	
  4)	
  
▪  Sites	
  
–  Oauth	
  Community	
  Site	
  -­‐	
  http://oauth.net/	
  
–  Parse.com	
 ...
Homework	
  &	
  More	
  to	
  Explore	
  
▪  Read	
  the	
  DocWiki	
  articles	
  and	
  blog	
  posts	
  for	
  REST	
 ...
Q&A	
  
Thank	
  You	
  J	
  
jim.mckeeth@embarcadero.com	
  
http://delphi.org/	
  
Upcoming SlideShare
Loading in …5
×

Accessing REST & Backend as a Service (BaaS) - Developer Direct - Mobile Summer School - 2014 - Lesson 6

2,603 views

Published on

Accessing REST Web Services and Backend as a Service (BaaS) from a native mobile app on Android and iOS using C++ or Object Pascal.

Published in: Software
  • Be the first to comment

Accessing REST & Backend as a Service (BaaS) - Developer Direct - Mobile Summer School - 2014 - Lesson 6

  1. 1. Lesson 6: Accessing  REST  and  Backend  as  a   Service  (BaaS)  Cloud  Services   Jim  McKeeth   Lead  Developer  Evangelist  –  Embarcadero   jim.mckeeth@embarcadero.com   http://delphi.org/  
  2. 2. Mobile  App  Development   ▪  Lesson  1  –  Hello  World!  My  First  Multi-­‐Device  App   ▪  Lesson  2  –  Turning  up  the  Style  and  Data!   ▪  Lesson  3  –  Accessing  Local  Storage  and  Databases   ▪  Lesson  4  –  Building  Multi-­‐tier,  Multi-­‐device  Apps  using  DataSnap  REST/JSON   ▪  Lesson  5  –  Connecting  Mobile  and  Desktop  using  App  Tethering   ▪  Lesson  6  –  Accessing  REST  and  BaaS  Cloud  Services   Replay  links  and  lesson  slides  will  appear  on  David’s  blog   http://blogs.embarcadero.com/davidi/  
  3. 3. Lesson  6  Agenda   ▪  REST  Client  Library   ▪  REST  Debugger   ▪  Backend  as  a  Service  (BaaS)   ▪  Samples  and  Snippets   ▪  Continue  development  of  the  mobile  business  app   ▪  Review,  Homework  and  Next  Time   ▪  Q&A  
  4. 4. REST  Client  Library   ▪  Framework  for  accessing  REST-­‐based  web  services   ▪  The  framework  focuses  on  JSON  as  the  representation  format.  XML  is  not   explicitly  supported.   ▪  The  framework  includes  components  and  is  built  around  3  main  components:   –  The  client  -­‐  TRESTClient   –  The  request  -­‐  TRESTRequest   –  The  response  –  TRESTResponse   ▪  Most  REST  services  require  authentication.  Components  are  provided  for   –  Simple  authentication  –  TSimpleAuthenticator   –  HTTP  basic  authentication  –  THTTPBasicAuthenticator   –  OAuth1  and  OAuth2  authentication  –  TOAuth1Authenticator  and  TOAuth2Authenticator  
  5. 5. REST  Client  Library  Components   ▪  TRESTClient  -­‐  manages  the  HTTP  connection  to  the  service,  deals  with  HTTP   headers  and  proxy  servers,  and  receives  the  response  data.   ▪  TRESTRequest  -­‐  holds  all  parameters  and  settings  that  form  the  actual  HTTP   request  to  a  Web  service.  When  connected  to  a  client-­‐component,  it  can  be   executed  (even  at  design  time).   ▪  TRESTResponse  -­‐  holds  all  the  returned  data  from  a  Web  service.  The  returned   data  includes  the  HTTP  status  code,  error  messages  (if  any  exist),  and  the  returned   JSON  data.   ▪  TRESTResponseDataSetAdapter  –  takes  the  returned  JSON  data  and  converts  it   to  a  form  a  DataSet  can  use  –  for  example  TDataSet  and  TFDMemTable.   ▪  Authenticator(s)  -­‐  most  services  require  an  authentication  before  they  can  be  used.   The  authenticator  components  are  used  to  apply  the  specific  authentication   methods  that  are  required  by  the  REST  service.  An  authenticator  is  attached  to  the   client  and  is  automatically  executed  on  each  executed  request.  You  can  create   custom  authenticators  using  the  TCustomAuthenticator  class.  
  6. 6. REST  Debugger   ▪  Included  on  the  Tools  Menu   ▪  Use  it  to  making  queries  to  test  and   debug  REST  queries  before  applying  them   to  your  own  REST  applications.   ▪  The  interface  has  four  pages  that  contain   the  main  request  information,   the  resource  and  the  parameters  request,   the  authentication  methods,  and  the   option  to  use  proxy  to  connect  to  the   server.  
  7. 7. Cloud  Service  (BaaS)  Integration   ▪  Use  push  notifications  to  engage  your  users   ▪  Access  data  and  object  storage  in  the  cloud   ▪  Provide  user  authentication   ▪  Supports  popular  BaaS  providers  with  a   common  API  component  set   –  Parse   –  Kinvey   –  Additional  providers  to  appear  in  the  future     ▪  App42  has  a  provider  now   https://github.com/shephertz/App42-­‐AppMethod-­‐API    
  8. 8. BaaS  =  Backend  as  a  Service   ▪  Most  mobile  apps  need  server  storage  for  data,  images,  files,  etc   –  Build  yourself  (with  DataSnap)   –  Buy  a  scalable  cloud  solution  (with  Cloud  or  BaaS  services)   ▪  BaaS  =  cloud  solution  with  mobile  users  management   –  Services  also  provide  analytics,  push  notifications  (cross  platform  and  more)   ▪  REST  BAAS  framework  offers  you  a  variety  of  actions:   –  Create,  retrieve,  update  and  delete  objects   –  Sign  up,  login,  retrieve,  update  and  delete  users   –  Upload,  download  and  delete  files  or  streams   –  Query  objects  and  users   –  Send  push  notifications   –  Register  for  and  receive  push  notifications  on  a  device  
  9. 9. Backend-­‐as-­‐a-­‐Service  Client  Components   ▪  Based  on  REST  Client  architecture  that   was  introduced  in  XE5   ▪  BaaS  clients  for  Kinvey  and  Parse   –  Native  providers  to  use  services  directly   –  Providers  integration  with  framework  for   common  services   –  Framework  works  with  these  providers,   open  for  future  extensions   ▪  Providers  to  connect  to  Parse  and  Kinvey   service   –  TParseProvider   –  TKinveyProvider   –  TCustomProvider  –  to  implement  your  own   integration     ▪  Push  Notifications   –  TPushEvents  –  to  register  your  device/app   to  receive  notifications   –  TBackendPush  –  allows  an  app  (desktop  or   mobile)  to  push  a  notification  to  the   provider  service  that  passes  it  along  to   registered  devices   ▪  Storage   –  TBackendStorage   –  TBackendQuery   –  TBackendFiles   ▪  User  Management   –  TBackendUsers    
  10. 10. Backend-­‐as-­‐a-­‐Service  Model   ▪  Supports  abstract  features,  provider  independent   –  Create,  retrieve,  update  and  delete  (JSON)  objects   –  Signup,  login,  retrieve,  update  and  delete  users   –  Upload,  download  and  delete  files  or  streams   –  Query  objects  and  users   –  Send  push  notifications   –  Register  for  and  receive  push  notifications  on  a  device  
  11. 11. Push  Notifications  Scenarios   ▪  Send  reminders  to  mobile  apps  even  when  not  active   –  App  to  app  notifications  (via  push  server)   –  Server  to  app  notifications  (triggered  by  server  events)   –  Client  notifications  (for  example  VCL)  to  companion  app   è
  12. 12. REST  and  BaaS  Samples   ▪  REST  and  BaaS  mobile  samples   –  REST  –  SurfSpotFinder   –  BaaS  ToDo  List   –  C++   ▪  C:UsersPublicDocumentsEmbarcaderoStudio14.0SamplesCPPMobile  Samples Cloud   ▪  http://sourceforge.net/p/appmethod/code/HEAD/tree/branches/Appmethod_114W/ CPP/Mobile%20Samples/Cloud/   –  Object  Pascal   ▪  C:UsersPublicDocumentsEmbarcaderoStudio14.0SamplesObject  PascalMobile   SamplesCloud   ▪  http://sourceforge.net/p/appmethod/code/HEAD/tree/branches/Appmethod_114W/ Object%20Pascal/Mobile%20Samples/Cloud/   ▪  Always  be  sure  to  update  your  local  samples  from  Sourceforge!  
  13. 13. REST  and  BaaS  Demos  
  14. 14. Next  Steps  for  our  Business  Mobile  App   ▪  Use  the  REST  Client  Library  components  to  use  a  REST  service  (parts  lookup)   for  the  Parts  table   ▪  Use  BaaS  to  push  notifications  to  the  Marine  Adventures  mobile  app  to  tell   employees  that  an  order  has  shipped,  part  is  backordered  and  inventory  is   getting  low.  
  15. 15. Lesson  6  Review   ▪  Quickly  use  REST  Services  using  REST/JSON  and  the  REST  client  library   components   ▪  Extend  your  mobile  and  desktop  applications  into  the  Cloud  using  Backend  as  a   Service  
  16. 16. Resources  (1  of  4)   ▪  REST  Client  Library  -­‐  Docwiki   –  http://docwiki.appmethod.com/appmethod/1.14/topics/en/REST_Client_Library   –  http://docwiki.embarcadero.com/RADStudio/XE6/en/REST_Debugger   –  http://docwiki.embarcadero.com/RADStudio/XE6/en/Using_the_REST_Debugger   –  http://docwiki.appmethod.com/appmethod/1.14/codeexamples/en/RESTDemo_Sample   ▪  Tutorial   –  http://docwiki.appmethod.com/appmethod/1.14/topics/en/ Tutorial:_Using_the_REST_Client_Library_to_Access_REST-­‐based_Web_Services     Note:  http://docwiki.appmethod.com/appmethod/1.14/topics/en/...  =  http://docwiki.embarcadero.com/RADStudio/XE6/en/...  
  17. 17. Resources  (2  of  4)   ▪  BaaS  –  DocWiki   –  http://docwiki.appmethod.com/appmethod/1.14/libraries/en/REST.Backend   –  http://docwiki.appmethod.com/appmethod/1.14/libraries/en/ REST.Backend.ServiceComponents   –  http://docwiki.appmethod.com/appmethod/1.14/topics/en/Creating_the_Application   ▪  Tutorials   –  http://docwiki.appmethod.com/appmethod/1.14/topics/en/ Mobile_Tutorial:_Using_Remote_Notifications_(iOS_and_Android)   Note:  http://docwiki.appmethod.com/appmethod/1.14/topics/en/...  =  http://docwiki.embarcadero.com/RADStudio/XE6/en/...  
  18. 18. Resources  (3  of  4)   ▪  Videos  on  Demand   –  David  I  “BaaS  webinar”  replay   ▪  http://www.embarcadero.com/landing-­‐pages/rad-­‐in-­‐action-­‐baas   –  Sarina  Dupont  “Managing  User  Accounts  and  Storage  with  BaaS”  skill  sprint  replay   ▪  https://www.youtube.com/watch?v=Ct13YWSRP04   –  David  I  “BackendPush  skill  sprint”  replay   ▪  https://www.youtube.com/watch?v=N2_KA3LEWYw   –  Jim  McKeeth  “Integrate  Cloud  Services  with  the  REST/JSON  Client  skill  sprint”  replay   ▪  https://www.youtube.com/watch?v=sp-­‐EDTKy2BU   –  Stephen  Ball  on  Object  Persistence   ▪  http://blogs.embarcadero.com/stephenball/2014/04/23/remote-­‐object-­‐persistence-­‐with-­‐parse-­‐and-­‐kinvey/     ▪  http://blogs.embarcadero.com/stephenball/2014/06/05/apptethering-­‐leaderboard-­‐passing-­‐objects-­‐remotely-­‐ and-­‐using-­‐resources/    
  19. 19. Resources  (4  of  4)   ▪  Sites   –  Oauth  Community  Site  -­‐  http://oauth.net/   –  Parse.com  -­‐  https://parse.com/   –  Kinvey.com  -­‐  http://www.kinvey.com/     ▪  Blogs   –  http://blogs.embarcadero.com/   –  David  I  blog  –  “Finding  your  Tethered  Apps”     ▪  http://blogs.embarcadero.com/davidi/2014/04/28/43708   –  Sarina  Dupont  blog  –  Series  of  10  BaaS  tutorials   ▪  http://blogs.embarcadero.com/sarinadupont/2014/06/09/baas-­‐tutorials-­‐to-­‐help-­‐you-­‐get-­‐started-­‐quickly/   ▪  Or  http://embt.co/baastutorials     –  Stephen  Ball  on  Object  Persistence   ▪  http://blogs.embarcadero.com/stephenball/2014/04/23/remote-­‐object-­‐persistence-­‐with-­‐parse-­‐and-­‐kinvey/     ▪  http://blogs.embarcadero.com/stephenball/2014/06/05/apptethering-­‐leaderboard-­‐passing-­‐objects-­‐remotely-­‐ and-­‐using-­‐resources/    
  20. 20. Homework  &  More  to  Explore   ▪  Read  the  DocWiki  articles  and  blog  posts  for  REST  Client  Library  and  BaaS   ▪  Watch  the  videos   ▪  Go  through  the  Mobile  Snippets  and  Samples  for  additional  demos   ▪  Try  some  of  the  Mobile  Tutorials   –  Download  the  PDF  ebook  at   http://docs.embarcadero.com/products/rad_studio/radstudioXE6/ Mobile_Tutorials_en.pdf   –  The  individual  mobile  tutorials  are  listed  at   http://docwiki.appmethod.com/appmethod/1.14/topics/en/ Mobile_Tutorials:_Mobile_Application_Development_(iOS_and_Android)   ▪  Enhance  the  Marine  Adventure  mobile  app   Note:  http://docwiki.appmethod.com/appmethod/1.14/topics/en/...  =  http://docwiki.embarcadero.com/RADStudio/XE6/en/...  
  21. 21. Q&A  
  22. 22. Thank  You  J   jim.mckeeth@embarcadero.com   http://delphi.org/  

×