REST.BaaS ToDo Sample
This sample project demonstrates the use of Kinvey as a BaaS (Backend as a Service) provider to post and get data from your data collection.
You can find the BaaS_ToDo sample project at:
- Start | Programs | Embarcadero RAD Studio Sydney | Samples and navigate to:
Object Pascal\Multi-Device Samples\Cloud\BaaS
- Subversion Repository:
- You can find Delphi and C++ code samples in GitHub Repositories. Search by name into the samples repositories according to your RAD Studio version.
The BaaS_ToDo sample uses Kinvey as a BaaS provider to post and get data from a data collection. This demo requires that you sing up for an account with Kinvey.
Sing up with Kinvey
To use the sample, you need to create an app backend at Kinvey:
- Go to Kinvey website and create an account if you do not have one.
- Once you are logged in at Kinvey, go to your console and click the button to create a New App.
- Enter the name of the project.
- Select REST API as platform and click Create App.
- When the app is created, click on Development.
- In this screen, you can find the App ID, App Secret, and Master Secret that are required for the TKinveyProvider component.
How to Use the Sample
- Navigate to one of the locations given above and open:
- Delphi: BaaS_ToDo.dproj.
- C++: BaaS_ToDoCpp.cbproj.
- In the Projects Window, expand the DataModuleUnit1 node and double-click DataModuleUnit1.dfm (Delphi) or DataModuleUnit1.fmx (C++) to open the Data Module where the nonvisual components are located.
- Select the KinveyProvider1 component and in the Object Inspector set the AppKey, AppSecret, and MasterSecret to the values provided by Kinvey as commented in step 4 of the previous section (the Kinvey App ID corresponds with the App Key property).
- Select the wanted target Platform from the Project Manager.
- Only for C++: Go to Project > Options > C++ Linker and set Link with SSL and Crypto to
Trueunder iOS Device - 32 bit platform or iOS Device - 64 bit platform.
- Press F9 or choose Run > Run.
- Note: The device where you run the application must have access to the Internet.
- You can click the plus button to add an item, write the title and description of the item and click Save to save your item. This sends the information to Kinvey.
- To view the information in the Kinvey Console, you can refresh the Kinvey page and see how “Data” has new sub-section named ToDos.
- You can update the information in the BaaS ToDo Sample App. Click Refresh in the ToDos collection at Kinvey, to see how the information you change in the BaaS ToDo Sample App gets updated.
- Note: If you run the application and the data collection is not empty, you may have to click the RefreshList TButton to update the information and populate the ListView with the existing items.
Using a Different BaaS Provider
This sample uses Kinvey as BaaS (Backend as a Service) Provider. You can also use Parse as a BaaS provider. To use Parse, you must delete the TKinveyProvider component, add a TParseProvider component and select the Parse Provider in the Provider property of the TBackendStorage component.
|File in Delphi||File in C++||Contains|
The project itself.
The main form where the components are located.
Used to define and implement
Information about this sample.
One new class and one new record are developed in ToDoItemTypes:
TToDoclass represents the information that is stored in the ToDos Kinvey collection. This class has the
Contentproperties that corresponds with the title and content collection elements.
TToDoNamesrecord holds information such as TitleProperty, ContentProperty, BackendClassname, TitleElement, and ContentElement.
The Sample Project
The sample is divided in 3 parts:
- BaaS_ToDoForm: Implements the graphical interface. Calls to the DataModuleFormUnit1 are done from here in order to connect and manage data from the backend.
- DataModuleFormUnit1: Implements the backed connection.
- ToDoItemTypes: Defines and implements the TToDo class and the TToDoNames record.
- This sample uses the TBackendStorage component to post and get data from your data collection.
- The TKinveyProvider is used to set up the Kinvey connection to use Kinvey as a BaaS provider. The TBackendStorage and the TKinveyProvider components are connected as Kinvey is set in the Provider property of the TBackendStorage component.
- TTabControl component holds the TTabItems used to create the four different views of the application: List, Details, Add, and Edit.
- TListView component is used to present the data collection as a list of items in the Details view. TEdits and TMemos display the data in the rest of the views.
- TActionList holds the list of actions used by the components in response to user actions.
- TPrototypeBindSource has the two fields Title and Content, available in an item of the data collection.
- TBindingsList is used to create managed binding among the different components.
- BaaS Overview
- Getting Started with Kinvey and Parse
- Managing BaaS Users
- Using BaaS for Backend Storage
- Handling VCL Actions Using an Action List
- Mobile Tutorial: Using BaaS for Backend Storage (iOS and Android)
- Mobile Tutorial: Using Remote Notifications (iOS and Android)