How RhoSync Makes Smartphone App Integration Easier
In the last post we described the typical steps involved in building smartphone apps that integrate with enterprise application backends. The big tasks in writing mobile apps that do this are: connecting to backend apps, retrieving the data, parsing responses, populating the local database, secure storage, app and data deprovisioning, and data synchronization. In discussions with smartphone app developers writing apps in Objective C or Java, or using frameworks like Rhodes or PhoneGap, we usually hear that these tasks involved the majority of the development effort and code size.
In this post we will describe how the RhoSync App Integration Server and other components provided by Rhomobile help with each of these tasks, drastically reducing the effort involved in mobilizing an enterprise application. RhoSync automates most of this process by allow the developer to just provide a “source adapter” for each model. The RhoSync server then does all of the work to connect to the backend application, retrieve the data, parse the response, and populate a server cache (specifically a very efficient Redis database) with the information. The RhoSync server then monitors all of the smartphone devices that connect to it and efficiently sends them just changes to the information that they need. The RhoSync server can be used whether or not the smartphone app was written with the Rhodes framework. We ship with Objective C libraries with RhoSync. And we are working on a JavaScript -based RhoSync client which will allow you to use RhoSync from any smartphone operating system, including apps written with other frameworks.

Writing a RhoSync Source Adapter
Note that in most cases a “source adapter” must still be written to connect to the backend application. Specifically this means writing “query”, “create”, “update” and “delete” methods to interact with the backend system. The source adapter query method returns data in a standard “hash of hashes” result and the RhoSync server does the rest of the work to get all of the data down to the device’s database. The create, update and delete methods can expect information on the record to be created or updated or deleted to be provided to it by the RhoSync server. For example the query method might connect to the backend application’s REST interface, retrieve the data as a JSON payload and then put which typically exposes a REST or SOAP interface that the source adapter can consume. The code can be as simple as:
def query
items=JSON.parse(open("http://yourcompany.com/crm/accounts.json").read)
@result={}
items.each do |item|
@result[item["id"]]=item
end
end
Assuming an app that might just retrieve information those five lines of code replace hundreds of lines of Objective C or Java code of an app that might connect directly. And of course you get the benefit of automatically synchronized offline data in the process. And note that often a RhoSync source adapter already exists for the enterprise backend application that you have in mind. RhoSync ships with source adapters for SalesForce. And there are third party source adapters for other CRM systems such as Oracle (Siebel) and SugarCRM.
Bulk Sync
With the creation of a source adapter then, RhoSync handles the connection and retrieval of data, parsing the response and populating the local database. Note that RhoSync also handles performing large database delivery through its “bulk sync” feature. If bulk sync is turned on the RhoSync server will create a SQLite database on the server and send it down to all devices compressed. This is very helpful for model (business objects) with large amounts of data such as product catalogs or customer account lists.
Rhodes Automatic Encryption
For sensitive data (such as patient information in a medical information system or personal financial information in a banking system) the enterprise will often want to have the data be stored encrypted on the device. If the smartphone app is written with Rhodes and the “secure app” option is turned on then the data will be populated in encrypted form into the database. No code to perform encryption needs to be done in the smartphone app.
Automated Deprovisioning
Another concern when integrating smartphone apps with critical enterprise systems is what happens if a device is lost or stolen or an employee is terminated. The RhoGallery feature on RhoHub allows apps and data to be deprovisioned whenever the IT administrator chooses.
Synchronization
We have described primarily how RhoSync eases the app integration process versus writing code directly from the device to integrate with backends. But of course RhoSync also provides for synchronized offline data. This means users can use their apps completely whether or not they are connected to the Internet from their device at a given time. It also means a higher perceived level of performance for the user. The data is just always present on the device. The user doesn’t have to wait for information to be retrieved from the backend.
Note that writing an app that just retrieves information and stores it on the device is not synchronized offline data. One reason is lack of “push data”: data must be retrieved by explicit request or action by the user. With RhoSync data can be pushed to the device realtime (it is unusual to unheard of for “manually written direct from device to backend application sync” to do push data). Another is that without a server like RhoSync to keep track of the “master list of data” the device cannot just receive only the changes.
True “No Code” Integration for Ruby on Rails Developers
If you are writing your backend application in Ruby on Rails we will soon be providing a Rails plugin that literally removes all of the code necessary to synchronize the data to the smartphone app on the device. In other words a source adapter is no longer necessary. By including the “RhoSync Rails plugin” in your Rails app, your Rails app will push data through RhoSync directly to the device. Data associated with all models (or selected models) of your Rails app is just replicated efficiently down to the device. No source adapter needs to be provided at all.
Summary
RhoSync makes it much easier to integrate smartphone apps with enterprise backend applications. It automates much of the repetitive and laborious process involved in integrating with backend data feeds. In some cases RhoSync can remove literally all of the code required to integrate with a backend app. Use of Rhodes to write your app makes encryption of data automatic where appropriate. And using RhoGallery to manage your apps handles the app deprovisioning and management issues with enterprise apps and data. Regardless of whether you use RhoSync and other Rhomobile components or not, you should think carefully through all of the common steps identified in enterprise application integration and make sure your development plan addresses each of them.