API: Check Dropbox Status

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.

Requirements

Kiosk Pro Plus and Enterprise

  • Integration of our JavaScript API into your webpage
    • Sample code to run within the app and download for integration into your own project is available here.
    • Best practices for working with the JavaScript API are available here.
  • App Settings
    • Content > JavaScript API > Access JavaScript API = By Import
    • Dropbox Sync
      • Enable = On
      • Account Information = must be linked to your Dropbox account


Triggers via API Functions

Check Dropbox Sync Status

This function checks the current sync status of Dropbox's servers and, if needed, syncs any files that are not current.

Format
kp_DBXSyncManager_sync();
		
Triggers This call triggers kp_DBXSyncManager_syncOperationDidSchedule when checking the sync status begins. If a sync is needed, this call will then trigger a sync and track the sync using the callbacks kp_DBXSyncManager_syncOperationDidStart and kp_DBXSyncManager_syncOperationDidFinish.


Allow Specific Files to Sync

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

Format
kp_DBXSyncManager_startObservingChangesOfType(type);
		
Parameters
  • type = [integer] the 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.


Prevent Specific Files from Syncing

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

Format
kp_DBXSyncManager_stopObservingChangesOfType(type);
		
Parameters
  • type = [integer] the 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.


Check Sync Status of Specific Files

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

Format
kp_DBXSyncManager_getTypeOfObservingChanges(callback);
		
Parameters callback = [string] callback name
Callback Format
callback(type);
		
Return Values
  • type = [integer] 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.

Notifications via API Callbacks

When a Sync Status Check is Triggered

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 = [integer] 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.


When Syncing Starts

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 = [associative array] contains information on the files to be synced during the current sync cycle with the following key-value pairs:
    • localPath = [string] local file path of the file being synced
    • dbPath =[string] Dropbox file path of the file being synced
    • syncType = [integer] explains why sync was triggered for this file. 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 = [integer] status of sync. Possible values are:
      • 0 = sync not complete.
      • 1 = sync complete.


When Syncing End

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 = [associative array] contains information on the files to be synced during the current sync cycle with the following key-value pairs:
    • localPath = [string] local file path of the file being synced
    • dbPath =[string] Dropbox file path of the file being synced
    • syncType = [integer] explains why sync was triggered for this file. 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 = [integer] status of sync. Possible values are:
      • 0 = sync not complete.
      • 1 = sync complete.


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 https://kioskgroup.com/dropbox-api
  • To download a .zip of sample code, click here.

Change Log

  • Added in version 3.5.2.

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