Message:

  • Home
  • Articles by: Anton Govorushkin

Author Archives

Since Backendless does not have native APIs to download files, today we’ll talk about how to implement this function in your Android application. In order to do that, we’ll need to combine Backendless file listing API and android.app.DownloadManager. There are several alternatives to this approach, but the selected one requires less code to write and has a well-thought structure.

Once a developer uploads files to the Backendless Files system, each file gets a public URL which can either be obtained using the Backendless Console or calculated using the following URL scheme:


publicURL 1024x472 - How to download a file stored in Backendless with your Android appThis public URI is the full path to the file in your Backendless file system. Directory listing API returns a list of the  FileInfo objects representing the files located in the directory, where each element in the collection contains the following properties:
Continue reading

Backendless Marketplace is a specialized store for backend functionality. Our vision for the marketplace is to make it a community driven store for algorithms and API services. We also use the Marketplace for various  Backendless”extenders” to help developers to increase the limits of the Backendless Cloud pricing plans. However, most importantly, the Marketplace can be used for sharing your API services with other developers.

By publishing your Cloud Code to the Marketplace, you can share your business logic components (e.g.: API services, event handlers and/or timers) with other Backendless developers. Once your Cloud Code is published, it becomes a Marketplace product and will be visible to all Backendless users (developers). In the upcoming releases, we’ll add a possibility to set a price for your products allowing you to charge a fee for every successful installation.

Backendless Marketplace   Backend as a Service Platform Google Chrome 2018 05 31 21.54.32 1024x568 - How to publish a service to Backendless Marketplace

Continue reading

In this article, we’ll talk about Backendless publish-subscribe messaging. One of the frequent questions we receive is: ‘How to get messages long after they are published.’ The default mechanism in Backendless keeps messages in the published channel for a short period of time only (around a minute). This becomes a problem if subscriber needs to have access to the messages after that time period has passed. This article describes an approach for storing published messages in Backendless database in order to keep published messages accessible even when they are no longer present in a messaging channel.

Publish-subscribe is a Backendless messaging pattern. The main idea here is to exchange data between a publisher* and subscriber** within a messaging channel***.

publisher – a program using the Publishing API to send messages to a channel.
** subscriber – a program using the Subscription API to receive messages from a channel.
*** channel – a logical intermediary “transporting” the messages.

In order to keep messages accessible for an infinite period of time – you can save messages into the Backendless database right after they were published. To accomplish this, we’ll need to combine Data service API and the afterPublish event handler which can be added to the Business Logic tab of your Backendless application.

handlerConfig 1024x565 - How to save published messages in the database

Once it’s added, just download the afterPublish handler code from ‘Download’ menu (you can select JavaScript or Java). Then open the generated project in any IDE and add the code to store published messages in a Backendless data table.

Alternatively, the afterPublish event handler can be added and deployed to cloud without any coding at all using Codeless business logic. Here are the steps of how it can be done:
1. Add new Codeless event handler Selection 143 1024x519 - How to save published messages in the database2. When the handler is saved, Codeless designer will be opened. Add the following blocks to your Codeless logic. When done – click the ‘DEPLOY MODEL’ button.
Selection 144 1024x535 - How to save published messages in the database
Voila!

To avoid nulls, every message should be published with a not null value for publisherId :

For this scenario we’ll need to create a data table (Data > APP TABLES in your Backendless application) called ‘ChatHistory’ and define the following schema in it:

  • Column publisher of type String 
  • Column messageData of type String 

dataTable 1024x557 - How to save published messages in the database

Once code for the handler is added, deploy the handler code to cloud using the following command in your IDE terminal:
./bin/Deploy.sh
Since the handler is deployed, every new message published to chatRoom channel will be stored in a dedicated data table and will be accessible at any required moment by calling an API to retrieve data from a table:

You will receive the following output:

Find us in facebook