Efficient MobileTogether Services on Backend Servers for Mobile Apps

MobileTogether Server Advanced Edition services on backend servers for mobile apps execute independently of any app running on a mobile device, based on a variety of triggers. MobileTogether services can provide background functionality to mobile apps or perform automated standalone actions without requiring any end user to interact with a mobile app. For instance, a MobileTogether service could generate a report and email it to the server administrator at a specified time. Or, a service could query a database based on some external criteria and perform an action such as sending a notification or an email.

A MobileTogether Server service is a set of MobileTogether Designer actions deployed to the server as a specialized solution file.

MobileTogether services on backend servers for mobile apps share some functionality with mobile apps, but have no user interface. For instance, services can use all the same data sources as a mobile app: an XML, HTML, or JSON data structure, an HTTP/FTP request, a database, or an XQuery tree.

Developers who are already familiar with the MobileTogether Designer paradigm for cross-platform rapid mobile app development (RMAD) will be able to leverage their experience to quickly design services.

A MobileTogether Server service is created by selecting New Service from the MobileTogether Designer File menu, which opens a simplified version of the Designer. Services do not require any mobile app interface, so helper windows for pages and user controls are inactive.

Let’s create a service that queries a sales database to retrieve the count of products sold in a day, converts the query results to structured XML data, sends an email to the sales administrator with the XML data attached as a file, and sends a notification to selected company executives. We’ll use the sales database included with the MobileTogether CompanySales demo app that is installed automatically with the MobileTogether Designer and deployed on the MobileTogether Demo Server.

Our service will need a database query and an XML structure, as seen in the Page Sources screenshot below:

Data sources for a MobileTogether Server Service

The service also contains a structure called Triggers that will exist on the MobileTogether Server. We will define triggers later when we deploy the service.

Once the Pages Sources are complete, we can define the MobileTogether Actions to be executed when the service runs. The Design Pane, which is normally used to create page layouts for mobile apps, now contains a large button that opens the Service Action Tree, where we will define actions for the service.  A list of all available actions for MobileTogether Server services is shown in this screenshot:

Actions available to MobileTogether Server services

Note that all MobileTogether actions related to page navigation, user interface, or user functionality are grayed out to indicate they are not available for services on backend servers for mobile apps.

A MobileTogether Server service executes a single set of actions, which will likely contain multiple steps and could perform complex if-then-else logic, call subroutines defined in separate Action Groups, etc.

The Actions performed by our sales report service are shown below. The service executes the database query, runs a loop to update the XML structure with query results, and calls action groups to send the email and push notification.

Actions performed by the service for backend servers for mobile apps

Here is the Send email action group for the designated recipient:

Send email action group for the service

The email action allows us to send the XML data as a file attachment without ever saving any intermittent file in any other location.

The action group for our push notification is shown below. We can send a push notification addressed to three users by their MobileTogether user names.

The notification action also allows us to send a data payload to a MobileTogether solution. The CompanySales app runs its own series of queries against the sales database, so we don’t need a payload for this notification.

Services for backend servers for mobile apps are deployed via the Deploy option in the MobileTogether Designer File menu. The deployment dialog for services includes a special option to open the MobileTogether Server Web browser interface and define triggers that will execute the service:

MobileTogether services option to edit triggers

Three types of triggers can execute the service: timers, file system changes such as a watched hot folder or file, and HTTP triggers. For initial testing, we can define a Timer to execute the service once:

MobileTogether service trigger for testing

The timer triggers execution and the Server Log view indicates success. The Finished service entry at the top indicates success and the entry immediately below traces execution in step-by-step detail, beginning with the database query.

MobileTogether log for service test execution

To save space we truncated the screenshot, but it continues all the way to generation of the email message and the notification.

Here is the email attachment viewed in a window in the Altova XMLSpy XML Editor:

XML view of email attachment generated by the MobileTogether service

Here are the notifications delivered to an Android device and an iPhone:

Notification on an Android device

Notification on an iPhone

When any recipient taps the notification, the CompanySales app is launched, providing rich detail about the day’s sales.

The MobileTogether CompanySales demo app

The test result is exactly what we want, so we can define a new trigger to execute the service every day after the close of business hours:

Production trigger for a service for backend servers for mobile apps

Find out for yourself how easy it is to define services on backend servers for mobile apps and create your own rich cross-platform mobile apps with many advanced features by building an app in the free MobileTogether Designer.

Tags: , , ,
1 reply

Comments are closed.