• <GetStart>
  • CSPro User's Guide
    • The CSPro System
    • Data Dictionary Module
    • The CSPro Language
    • Data Entry Module
    • Batch Editing Applications
    • Tabulation Applications
    • Data Sources
    • Synchronization
    • CSPro Statements and Functions
      • Statement Format Symbols
      • Alphabetical List of Functions and Statements
      • List of Reserved Words
      • Deprecated Features
      • Declaration Statements
      • Numeric Values
      • String Values
      • Symbol Functions
      • Item Functions
      • Array Object
      • Audio Object
      • Barcode and QR Codes
      • Case Object
      • Document Object
      • File Object
      • Freq Object
      • Geometry Object
      • HashMap Object
      • Image Object
      • List Object
      • Map Object
      • Path
      • Pff Object
      • StringWriter Object
      • SystemApp Object
      • ValueSet Object
      • Program Control Statements
      • Assignment Statements
      • Data Entry Statements and Functions
      • Batch Edit Statements
      • Numeric Functions
      • String Functions
      • Multiple Occurrence Functions
      • General Functions
      • Date and Time Functions
      • External File Functions
      • Synchronization Functions
        • SyncConnect Function
        • SyncServer Function
        • SyncDisconnect Function
        • SyncData Function
        • SyncFile Function
        • SyncMessage Function
        • SyncParadata Function
        • SyncApp Function
        • SyncTime Function
        • GetBluetoothName Function
        • SetBluetoothName Function
    • Text Templates
    • Templated Reporting System
    • HTML, Markdown, and JavaScript Integration
    • Action Invoker
    • Appendix
  • <CSEntry>
  • <CSBatch>
  • <CSTab>
  • <DataManager>
  • <TextView>
  • <TblView>
  • <CSFreq>
  • <CSDeploy>
  • <CSPack>
  • <CSDiff>
  • <CSConcat>
  • <Excel2CSPro>
  • <CSExport>
  • <CSIndex>
  • <CSReFmt>
  • <CSSort>
  • <ParadataConcat>
  • <ParadataViewer>
  • <CSCode>
  • <CSDocument>
  • <CSView>
  • <CSWeb>

SyncApp Function

Format
b = syncapp();
Description
The syncapp function updates application files, such as a .pen and .pff, from a new version of the application package (package.json) on a synchronization service. This function is used to make updates, such as bug fixes and other modifications, to an application already deployed on mobile devices in the field.
This function only works on Android. It is not supported on Windows.
The function checks for an updated version of the application on the synchronization service that the program is currently connected to from a previous call to syncconnect. If the version of the application on the service is newer than the currently running version, then the new package is downloaded and the application on the device is updated.
Using syncapp is typically only for advanced scenarios, such as when you want to update an application over Bluetooth or when you want to initiate an update from within a menu program. In most cases it is simpler to use Update Installed Applications from the menu in CSEntry's Entry Applications screen as it does the same update as syncapp without requiring any custom logic.
Before calling syncapp, you must first connect to a synchronization service by calling syncconnect.
To use the syncapp function, you must first upload the application package to a synchronization service using the Deploy Application tool. The syncapp function looks for a package on the service with the same package name as the currently running application. If no package matching the current package name has been deployed to the service, the function will display an error. Note that the application package is not necessarily the same as the name of the .pen file. The package name is the name that was entered in the Deploy Application tool when the package was deployed to the service. It is important therefore to always use the same package name whenever deploying updates to an application.
The syncapp function only downloads the application if the version of the application on the synchronization service is more recent than the version on the mobile device. This is accomplished by storing the date and time the package was uploaded to the service by the Deploy Application tool. This date and time is stored in the application package and is used to determine if the package on the service is newer than the package on the mobile device.
Furthermore, if you are using CSWeb or Bluetooth, in order to keep data usage to a minimum, only files that are different than those in the version on the mobile device are downloaded. This way if you have large files in your application package that do not change as part of the update, they will not slow down the update. This optimization is not done for Dropbox or FTP.
Files in the downloaded package overwrite the corresponding files on the mobile device. To avoid generating multiple copies of the same file, use the same directory layout, file and folder names in the updated package as were used in the original package.
Files that are marked Only on first install in the deployment package that already exist on the mobile device will be ignored by syncapp and are not updated even if a newer version is included in the updated package.
Be careful when including data files in an application package that is used with syncapp as any data files that are in use by the current application will be locked which will result in errors when syncapp attempts to overwrite them. Either close any files that may be updated prior to calling syncapp or mark the data files as Only on first install in the Deploy Applications tool and use syncdata to update them instead.
Note that if as part of the application update the currently running .pen file is updated to a newer version, syncapp will restart the application in order to run the updated version. This means that any logic that follows the call to syncapp will not be executed. To avoid problems, make sure that the call to syncapp is the last call in the procedure. For example, to combine the application update with calls to syncdata to update data, place the calls to syncdata before the call to syncapp.
Return Value
The function returns a logical value of 1 (true) if the update was successful and 0 (false) otherwise.
Example
if syncconnect("https://example.org/csweb/api") then

   
// get the latest versions of the application files from CSWeb
    syncapp();

   
syncdisconnect();

endif;
See also: Synchronization Overview