• <GetStart>
  • CSPro User's Guide
    • The CSPro System
    • Data Dictionary Module
    • The CSPro Language
    • Data Entry Module
    • Batch Editing Applications
    • Tabulation Applications
    • Data Sources
    • CSPro Statements and Functions
      • Statement Format Symbols
      • Alphabetical List of Functions and Statements
      • List of Reserved Words
      • Deprecated Features
      • Declaration Statements
      • 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
      • 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
        • SyncConnect Function (CSWeb)
        • SyncConnect Function (Bluetooth)
        • SyncConnect Function (Dropbox)
        • SyncConnect Function (LocalDropbox)
        • SyncConnect Function (LocalFiles)
        • SyncConnect Function (FTP)
        • SyncServer Function
        • SyncDisconnect Function
        • SyncData Function
        • SyncFile Function
        • SyncMessage Function
        • SyncParadata Function
        • SyncApp Function
        • SyncTime Function
        • GetBluetoothName Function
        • SetBluetoothName Function
    • Templated Reporting System
    • HTML and JavaScript Integration
    • Action Invoker
    • Appendix
  • <CSEntry>
  • <CSBatch>
  • <CSTab>
  • <DataViewer>
  • <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 server. 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.
The function checks for an updated version of the application on the server that the program is currently connected to from a previous call to syncconnect. If the version of the application on the server is newer than the currently running version, then the new package is downloaded from the server and the application on the device is updated.
This function only works on Android. It is not supported on Windows. It may be used with CSWeb, Dropbox and FTP servers as well as with peer to peer synchronization via Bluetooth.
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 the Entry Applications screen of CSEntry as it does the same update as syncapp without requiring any custom logic.
Before calling syncapp, you must first connect to a server by calling syncconnect.
To use the syncapp function, you must first upload the application package to a server using the Deploy Application tool. The syncapp function looks for a package on the server with the same package name as the currently running application. If no package matching the current package name has been deployed to the server, 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 server. 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 server 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 server 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 server is newer than the package on the mobile device.
Furthermore, if you are using a CSWeb server or Bluetooth, in order to keep data usage to a minimum, only files that are different in the version of the package on the server from 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 servers.
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 since 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 files, 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(CSWeb,"https://www.myserver.org/api") then

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

   
syncdisconnect();

endif;
See also: Synchronization Overview, SyncConnect Function, SyncData Function, SyncDisconnect Function, SyncServer Function