GeneXus developers build their Smart Device applications online because it is easier for prototyping and testing. But, at some point they may need to turn their online apps into offline apps to get the benefits of an offline application.
GeneXus has useful features to handle this conversion quickly. Converting an online application into an offline application is as simple as changing a property value in your application's main object. In addition, it is also available for developers to manage several behaviors of their offline applications such as synchronization mechanisms, data storage in the device, and many others.
The first thing you should do is change the Connectivity Support property of the main object to Offline. Next, you have to do a "Rebuild All" of the main object.
You can learn more about this property in the article HowTo: Using the Connectivity Support property.
When GeneXus has finished building, your offline application is completed and ready to be installed on your device. Read Smart Devices Offline Applications Requirements for more details.
You can also change many behaviors as desired.
Choose your preferred way of receiving data from the server by changing these properties:
Data Receive Criteria property: Choose when to receive the data from the server.
Data Receive Granularity property: Choose how handle the changes to be synchronized.
Choose your preferred way of sending data from the device to the server by changing the Send Changes property.
Choose which tables of your system should be in your offline application. Read the article Offline Database Object Table selection to learn more.
Indicate which data the application stores in its offline database. Read the article Offline Database Object conditions for more details.
In order to use the GeneXus synchronization programs to send the changes made in the device to the server, the use of Business Component is necessary. The application sends in the synchronization process only Insertions, Deletions and Updates made by using Business Components. For this reason, it's important that you exclude the New, Delete and ForEach commands from your objects for inserting, deleting and updating data. Otherwise, the Warning spc0203 message will be shown during the Program Specification.
If you choose not to use the GeneXus synchronization programs, you can code your own Data Synchronization programs to send changes to the server.
At first sight, they may look the same, but they are different. The main difference is that WebSession data is lost every time the application closes, while the ClientStorage API stores the information to have the same information even if the application launches again.
Even if you have selected manual or automatic synchronization for receiving or sending data, the Synchronization API is always available, so that you can call the synchronization programs as needed. Read HowTo: Using the Synchronization API for further information.
Every time you use Business Components for Inserting, Deleting or Updating data in your device, those actions, also called events, are stored in an auxiliary table inside the application in order to send the same changes to the server later. You can manage those stored actions with the SynchronizationEventsAPI external object (X Evolution 3). For instance, you can change the actions' status if something goes wrong in the synchronization process or remove some of the actions if needed.
It is possible to have preloaded data in your application when installed on the device. For more information, read HowTo: Create offline SD applications with a preloaded database.
There are yet some non-implemented DataTypes for offline applications. Moreover, the specification error "spc0106" occurs for offline objects that use those DataTypes. So it is easy to know which are the non-implemented DataTypes for each platform.
Here is the list of non-implemented DataTypes for offline applications for each platform: Offline non-implemented DataTypes
It is recommended to avoid the use of those DataTypes in Smart Devices objects and use them in Server-only Procedures or Data Providers instead.
Sometimes you may have Procedures or Data Providers which execute only on the server side. For instance, Procedures that use components not implemented for Smart Device platforms yet -like PDF reports, Excel files, among others-, some Procedures that need high computational power, or some Data Providers that use files located in the server file system. However, because of the Smart Devices Offline Applications architecture, if an offline object calls some of these objects, they are going to be called offline and errors may occur while specifying or compiling the client-side application.
To run these objects online, a possible but a more intricate option is to call them via the HttpClient data type. However, the Connectivity Support property gives an easier solution for this problem: by setting this property to Online on Procedures, Data Providers or Business Component, whenever you call these objects from an Offline Smart Device object, the application calls these objects via REST services automatically. Another important fact is that these objects are generated only for the server-side application, avoiding many possible compilation errors from the client-side application.
The same way there might be some Procedures or Data Providers which have to be executed only on the server-side, there might also exist some Procedures or Data Providers which are only executable in the client-side, which means, these objects should be executed only by the device. This is very common in, for example, Procedures which uses External Objects which are defined only for Smart Device platforms. However, because of the Smart Devices Offline Applications architecture, if an offline object calls some of these objects, by default, these objects are generated for both client-side and server-side applications, so errors may occur while specifying or compiling the server-side application.
To avoid generating those objects for the server-side application, first be sure that the objects are not called by any Web object, and secondly set the Connectivity Support property of each Procedure or Data Provider to "Offline".
GeneXus Access Manager is available for Offline Smart Devices applications. Despite this, it has some restrictions that you should consider when converting your application from Online to Offline. For more details about this topic, read Offline Smart Devices applications using GAM.
Read Smart Devices Offline Applications Common Issues if you are having any trouble.