LiveSync Changes Programmatically

For hybrid mobile apps, developed with Apache Cordova, AppBuilder exposes a LiveSync JavaScript API which lets you work with the LiveSync three-finger refresh gesture from your code. With the window.livesync object and its sync() method, you can force LiveSync with the cloud from your code.

With the LiveSync JavaScript SDK, you can implement different functionality for the three-finger tap and hold gesture and still be able to get your latest code changes.

The LiveSync JavaScript API provides the following method for LiveSyncing changes programmatically.

  • sync() - Forces LiveSync, even if the LiveSync three-finger refresh gesture is disabled programmatically.

For example, when LiveSync is disabled programmatically, you can execute window.livesync.sync() from an Update button to let your testers get your latest code changes on demand.

IMPORTANT: Avoid executing window.livesync.sync() in your onDeviceReady event. This might cause your app to enter an endless loop of synchronizing changes and reloading.

Limitations

  • The LiveSync JavaScript API controls only LiveSync with the three-finger refresh gesture.
  • You can use the LiveSync JavaScript API to control LiveSync with the three-finger refresh gesture in the following cases.
    • When you build for the developer app.
    • When you build with the Debug build configuration.
  • The LiveSync JavaScript API works only for hybrid mobile apps developed with Apache Cordova.
  • If you are using the extension for Visual Studio to develop your app and your project is not connected to a cloud app, you need to synchronize your changes with the cloud before you can receive them on device. To synchronize your changes with the cloud, from the main menu bar, select AppBuilderSynchronize <app_name> with Cloud.
    For more information about how to connect your project with the cloud, see Collaborate Across the Offline and Cloud Tools.
  • If you are using the command-line interface to develop your app, you need to synchronize your changes with the cloud before you can receive them on device. To synchronize your changes with the cloud, run appbuilder livesync cloud

LiveSync JavaScript API Sample

For a complete sample that shows how to use the LiveSync JavaScript API, visit sample-livesync.

Next Steps

Continue development.

See Also

Start a free trial Request a demo
Contact us: +1-888-365-2779
sales@telerik.com
Copyright © 2016-2017, Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.