Trigger API: Dropbox Sync

This JavaScript API works with our Dropbox integration to allow you to check the status of sync operations, trigger a sync if you feel one is needed and track the progress of current sync operations. This API also allows you to start or stop syncing of files located either in Dropbox or on the device, limiting the amount of bandwidth used by the automatic Dropbox sync process.

While Kiosk Pro's Dropbox integration is designed to work automatically, triggering a new sync whenever changes are made to files, this API gives additional controls and visibility into that process.

Functions

Callbacks

Related Settings

Requirements

  • Access JavaScript API
    • By Import - recommended, works both online & offline, requires inclusion of kiosk_functions.js prior to any of the following calls.
    • By Injection - only works offline, may not be available 'onload' event.
  • Dropbox Synchronization
    • Enable = On.
    • 'Account Information' must be linked to your Dropbox account.

Sample Code

This sample code relies on the JavaScript APIs built into Kiosk Pro and will not run successfully in other browsers or within our in-app help interface.  
To run sample code, set the app's homepage to http://www.kioskproapp.com/dropbox

kp_DBXSyncManager_sync

This function triggers a check of current sync status with Dropbox's servers and, if needed, syncs any files that are not current.

Format
kp_DBXSyncManager_sync();
		

Status

When a check of current sync status begins, Kiosk Pro will call kp_DBXSyncManager_syncOperationDidSchedule().

If needed, this function will then trigger a sync operation which can be tracked through the callbacks kp_DBXSyncManager_syncOperationDidStart and kp_DBXSyncManager_syncOperationDidFinish.


kp_DBXSyncManager_stopObservingChangesOfType

This function prevents files stored in a specific location from triggering a sync cycle or being synced.

Format
kp_DBXSyncManager_stopObservingChangesOfType();
		
Parameters
  • type = type of sync prevented. Possible values are:
    • 0 = Only local changes. Changes to files stored locally in the Unique Content folder within Kiosk Pro will not trigger a new sync cycle and will not be synced to Dropbox.
    • 1 = Only Dropbox changes. Changes to files stored in Dropbox will not trigger a new sync cycle and will not be synced to Kiosk Pro.
    • 2 = All changes. Effectively turns off Dropbox sync - changes to files in Dropbox and in Kiosk Pro will both be ignored.
    • -1 = None. Default value, where changes to files stored locally in the Unique Content folder within Kiosk Pro and files stored in Dropbox both initiate a sync cycle.

kp_DBXSyncManager_startObservingChangesOfType

This function allows files stored in a specific location to trigger a sync cycle or be synced.

Format
kp_DBXSyncManager_startObservingChangesOfType();
		
Parameters
  • type = type of sync allowed. Possible values are:
    • 0 = local changes. Only changes to files stored locally in the Unique Content folder within Kiosk Pro will trigger a new sync cycle and will be synced.
    • 1 = Dropbox changes. Only changes to files stored in Dropbox will trigger a new sync cycle and will be synced to Kiosk Pro.
    • 2 = all changes. Default value, where any changes to files in both Dropbox and in the Unique Content folder within Kiosk Pro will trigger a new sync cycle.
    • -1 = none. Effectively turns off Dropbox sync - changes to files in Dropbox and in Kiosk Pro will both be ignored.

kp_DBXSyncManager_getTypeOfObservingChanges

This function triggers a callback allowing your code to check whether certain files are being synced.

Format
kp_DBXSyncManager_getTypeOfObservingChanges(callback);
		
Parameters callback = callback name as a string.
Callback format
callback(type);
		
Return values
  • type = type of sync currently allowed. Possible values are:
    • 0 = only local changes trigger sync.
    • 1 = only Dropbox changes trigger sync.
    • 2 = all changes trigger sync.
    • -1 = nothing triggers sync.

kp_DBXSyncManager_syncOperationDidSchedule

This callback is triggered whenever a check of sync status is started either automatically by the app in response to changes in files stored in Dropbox or the Unique Content folder on the device or through kp_DBXSyncManager_sync.

Format
kp_DBXSyncManager_getTypeOfObservingChanges(isScheduled);
		
Return values
  • isScheduled = indicates whether a new sync has been scheduled or a sync operation is currently in progress. Possible values are:
    • 0 = current sync operation is in progress.
    • 1 = new sync operation is scheduled.

kp_DBXSyncManager_syncOperationDidStart

This callback indicates a sync cycle has started and provides information on the files to be synced.

Format
kp_DBXSyncManager_syncOperationDidStart(arrayOfJobs);
		
Return values
  • arrayOfJobs = an associative array containing information on the files to be synced during the current sync cycle with the following key-value pairs:
    • localPath = local file path of the file being synced, returned as a string.
    • dbPath = Dropbox file path of the file being synced, returned as a string.
    • syncType = explains why sync was triggered for this file, returned as an integer. Possible values are:
      • 1 = local file to be updated.
      • 2 = local file to be created.
      • 3 = local file to be deleted.
      • 4 = Dropbox file to be updated.
      • 5 = Dropbox file to be deleted.
    • synced = status of sync, returned as an integer. Possible values are:
      • 0 = sync not complete.
      • 1 = sync complete.

kp_DBXSyncManager_syncOperationDidFinish

This callback indicates a sync cycle has completed and provides information on the files to be synced. As the kiosk is designed to refresh after new content is synced to the device so as to display any new content, you may not see the sync did finish event in every case.

Format
kp_DBXSyncManager_syncOperationDidFinish(arrayOfJobs);
		
Return values
  • arrayOfJobs = an associative array containing information on the files to be synced during the current sync cycle with the following key-value pairs:
    • localPath = local file path of the file being synced, returned as a string.
    • dbPath = Dropbox file path of the file being synced, returned as a string.
    • syncType = explains why sync was triggered for this file, returned as an integer. Possible values are:
      • 1 = local file to be updated.
      • 2 = local file to be created.
      • 3 = local file to be deleted.
      • 4 = Dropbox file to be updated.
      • 5 = Dropbox file to be deleted.
    • synced = status of sync, returned as an integer. Possible values are:
      • 0 = sync not complete.
      • 1 = sync complete.

Still stuck? How can we help? How can we help?