RAD Studio 10.4.1 is now available! Learn more. Looking for discounts? Visit our Special Offers page!
News

Using Delphi Parse API with Any Parse Server Hosting

The Parse web site (owned by Facebook) was retired earlier this year. This was a fairly popular BaaS (backend as a service) provider for mobile applications, but something you could use also from desktop apps. Delphi (and also C++Builder, btw) has included ready-to-use components for interfacing Parse APIs for quite some time. It was very easy to set up an account on the system and create an app. But the hosting was discontinued, and now what?

Additional Parse Hosting and the Delphi ParseProvider Component

While stopping the Parse web site, Facebook did you positive thing: they made the entire Parse server open source. So what happened is that many cloud hosting providers took that code and created compatible hosting services. By hosting the a fully API-compatible version of the Parse server, these providers made it possible to migrate client applications that were using parse with almost no effort. 

There was one additional issue to use these additional providers from Delphi. Given Parse applications were hosted on parse.com, the main domain name was hard-coded in our component. Now in Delphi Tokyo Release 1 (or 10.2.1) we have added a class helper that lets you easily change the URL provider. As you can read at https://quality.embarcadero.com/browse/RSP-13608 all you need to do is add the line:

ParseProvider1.BaseURL := ‘…’;

In a future release, this will become a property of the component, but to preserve compatibility it was added as a runtime only feature for Tokyo updates.

An Actual Example

To check this does really work I did the following. First I went to one of the Parse server providers that offers a limited free account, https://www.back4app.com/. By entering my credentials, in a minute I could create a test app and manually enter a user on their web console. The console configuration listed all of the parameters needed to connect.

Second I create a VCL forms application, with a ParseProvider component, a BackendUsers component, a button and a memo. In the ParseProvider I copied the various required IDs:

object ParseProvider1: TParseProvider ApplicationID = ‘esSv_______Whi’ RestApiKey = ‘mxBY______Wl6’ MasterKey = ‘kxW_____DHl’ end

The BackendUsers component only configuration is the connection to the provider (which should be automatic). Third step I wrote the following code to refer to the proper URL and get the list of users:

procedure TForm12.FormCreate(Sender: TObject); begin   ParseProvider1.BaseURL := ‘https://parseapi.back4app.com/’; end; procedure TForm12.Button1Click(Sender: TObject); var   aJSONArray: TJSOnArray; begin   aJSONArray := TJSOnArray.Create;   try     BackendUsers1.Users.QueryUsers([”], aJSOnArray);     Memo1.Lines.Add (aJSOnArray.ToString);   finally     aJSONArray.Free;   end; end;

You can see the result in the image below (sorry for the scanty UI):

That’s all it takes. So you can indeed keep using a Parse Server as a backend for your Delphi desktop and mobile applications, as long as you can find a suitable provider… or you can even self-host the open source version of Parse on your own servers.


Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial   Upgrade Today

   Free Delphi Community Edition   Free C++Builder Community Edition

About author

Marco is one of the RAD Studio Product Managers, focused on Delphi. He's the best selling author of over 20 books on Delphi.
Related posts
Delphi

Change notification bar color on Android

Delphi

How to Get IMEI on Android Devices with DELPHI 10.3 Apps

C++

#CodingResolutions: Programming Fundamentals - Functions

C++

#CodingResolutions: Strings and the RegExpDemo Sample App

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

IN THE ARTICLES