Accessing REST & Backend as a Service (BaaS) - Developer Direct - Mobile Summer School - 2014 -...
-
Upload
jim-mckeeth -
Category
Software
-
view
1.177 -
download
3
description
Transcript of Accessing REST & Backend as a Service (BaaS) - Developer Direct - Mobile Summer School - 2014 -...
Lesson 6: Accessing REST and Backend as a Service (BaaS) Cloud Services
Jim McKeeth Lead Developer Evangelist – Embarcadero [email protected] http://delphi.org/
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/
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
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
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.
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.
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
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
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
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
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
è
REST and BaaS Samples
▪ REST and BaaS mobile samples – REST – SurfSpotFinder – BaaS ToDo List – C++ ▪ C:\Users\Public\Documents\Embarcadero\Studio\14.0\Samples\CPP\Mobile Samples
\Cloud ▪ http://sourceforge.net/p/appmethod/code/HEAD/tree/branches/Appmethod_114W/
CPP/Mobile%20Samples/Cloud/
– Object Pascal ▪ C:\Users\Public\Documents\Embarcadero\Studio\14.0\Samples\Object Pascal\Mobile
Samples\Cloud ▪ 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!
REST and BaaS Demos
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.
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
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/...
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/...
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/
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/
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/...
Q&A
Thank You J
[email protected] http://delphi.org/