BaaS Overview

From RAD Studio
Jump to: navigation, search

Go Up to Developing RAD Server, Cloud, and REST Applications

BaaS (Backend as a Service) also known as MBaaS (Mobile Backend as a Service) allows connecting mobile (and also desktop) applications to cloud services.

RAD Studio provides the REST BaaS (backend-as-service) framework that allows you to connect your applications with the Kinvey and Parse BaaS providers.

Use the REST BaaS framework to connect with Kinvey or Parse BaaS providers in order to:

  • Create, retrieve, update and delete 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.

Getting Started with BaaS Providers

To be able to work with Kinvey and Parse as BaaS providers, you need to create an account. Then, to add this service to your applications, you need to create an app with the backend provider:

BaaS Account Information

Once you have created an app with the BaaS provider, Kinvey and Parse provide you with some keys that you need to add in the Kinvey provider component and Parse provider component of your RAD Studio application.

Kinvey keys:

Kinvey key name Property
App Key (or App ID) TKinveyProvider.AppKey
App Secret TKinveyProvider.AppSecret
Master Secret TKinveyProvider.MasterSecret

Parse keys:

Parse key name Property
Application ID TParseProvider.ApplicationID
Master Key TParseProvider.MasterKey
REST API Key TParseProvider.RestApiKey

REST.Backend API

The REST.Backend API provides a set of components to work with Kinvey and Parse to manage things such as users, storage, files, queries, push notifications and events.

REST.Backend Components

The REST.Backend components support BaaS services in a general or abstract way. The code you write using this components is not specific to Kinvey or Parse. For example, when you use the TBackendStorage component to create an object, the code is the same whether you are creating a Kinvey object or a Parse object.

The REST Backend components depend on backend service implementations to make the calls to Kinvey or Parse. For example, there is a Kinvey storage service which can be used by the TBackendStorage component.

To create a BaaS application, you should include a provider component such as TKinveyProvider or TParseProvider with the appropriate connection information for the Cloud service supplied by the BaaS provider. To connect a provider component with a service component you must indicate the provider component in the Provider property of the service component, such as TBackendStorage.Provider. The below tables show the BaaS Provider Components and the Service Components:

BaaS Provider Component Description
TKinveyProvider Kinvey BaaS provider, component that contains the information about the Kinvey could service connection
TParseProvider Parse BaaS provider, component that contains the information about the Parse could service connection.

Service Component Description
TBackendStorage Use this component to create, retrieve, update and delete objects.
TBackendUsers Use this component to perform user actions such as: sign up, log in, retrieve, update or delete users.
TBackendFiles Use this component to upload and delete files or streams.

Note: This component does not download files. Use the REST class TDownloadURL to download files.

TBackendQuery Use this component to query object, users and other types.

Note: Different service implementation may support queries on different types. For example, the Kinvey service implementation can query files and Parse implementation cannot.

TBackendAuth Use this component to manage user authentication such as log in and sign up.
TBackendPush Use this component to send push notifications.
TPushEvents Use this component to listen for push notifications messages.

REST.Backend Methods

The REST.Backend.KinveyApi and REST.Backend.ParseApi REST API units allow you to execute Kinvey and Parse REST API methods.

These units declare methods that map directly onto the REST API of the BaaS supplier. Use these units to write code to call REST API endpoints in Kinvey or Parse. The code you write using these units will be specific to Parse or Kinvey.

Check the below tables to see the REST.Backend methods you may use, as well as the resources and verbs used.

Methods from REST.Backend.KinveyApi:

TKinveyApi Method Resource Verb
AppHandshake AppData GET
CreateAppData AppData POST
FindAppData AppData GET
DeleteAppData AppData DELETE
UpdateAppData AppData PUT
QueryAppData AppData GET
UploadFile Blob POST
DeleteFile Blob DELETE
DownloadFile Blob GET
QueryFiles Blob GET
RetrieveFile Blob GET
SignupUser User POST
LoginUser User POST
RetrieveUser User GET
RetrieveCurrentUser User GET
UpdateUser User PUT
DeleteUser User DELETE
SuspendUser User DELETE
PushRegisterDevice Push POST
PushUnregisterDevice Push POST
Note: The resources of the above table refer to the following: AppData is data stored in the cloud, Blob are files (such as images, video and other), User is user and Push is push notification.

Methods from REST.Backend.ParseApi:

TParseApi Method Resource Verb
CreateClass Classes POST
DeleteClass Classes DELETE
FindClass Classes GET
UpdateClass Classes PUT
QueryClass Classes GET
UploadInstallation Installations POST
UpdateInstallation Installations PUT
DeleteInstallation Installations DELETE
QueryInstallation Installations GET
PushToDevices Push POST
PushBroadcast Push POST
PushWhere Push POST
UploadFile Files POST
DeleteFile Files DELETE
SignupUser Users POST
LoginUser Users GET
UpdateUser Users PUT
DeleteUser Users DELETE
QueryUsers Users GET
Note: The resources of the above table refer to the following: Classes are objects, Installation is an instance of the app being installed on a device, Push is push notification, Files are files and Users are users.

You may also check the API documentation from the BaaS providers:

Visual LiveBindings

Some BaaS components have support for Visual LiveBindings, so you can use the LiveBindings Designer to connect properties of the components to controls of your form.

Property Value Typical binding control
TBackendQuery.JSONResult Result of the query (TJSONArray). TMemo
TBackendQuery.BackendClassName Collection or Class name when querying storage. TEdit
TBackendQuery.BackendService What to query: Storage, Users, Installations, Files, and so on. TEdit
TBackendQuery.QueryStrings Query strings. The strings must be valid for the particular cloud service. TMemo
TBackendPush.GCM.Action Action field of the push message (Android). TEdit
TBackendPush.APS.Alert Alert field. TEdit
TBackendPush.APS.Badge Badge field (iOS). TEdit
TBackendPush.APS.Sound Sound field (iOS). TEdit
TBackendPush.GCM.Title Title field (Android). TEdit
TPushEvents.JSONResult JSON array of all messages that have been received. TMemo
TPushEvents.Active Listen for push messages. TCheckBox

BaaS Topics

See Also

Code Samples