Programmatic LiveSync

Hybrid

Filter by IDE
Select the AppBuilder client you are currently using for development.

IDE

Programmatic LiveSync

Try in the Platform

Overview

This sample shows how to use the LiveSync JavaScript API to control LiveSync in your apps programmatically. It provides three buttons from which you can call each method.

Supported mobile platforms: iOS 7.1+, Android 4.4+, Windows Phone 8.1+

Developed with: Windows Phone SDK 8.1, Apache Cordova 4.0.0

Back to Top

API

The LiveSync plugin's JavaScript API consists of the following methods of the global livesync object:

  • sync(successCallback, errorCallback) - performs a full project sync
  • enable() - enables the 3-finger LiveSync gesture
  • disable() - disables the 3-finger LiveSync gesture
  • forceIndexReload(force) - sets the option to always reload the index page on LiveSync. Currently supported only for Android platform on which by default a single file sync via USB causes refresh of the currently open page
  • getForceIndexReload(successCallback, errorCallback) - gets the current value of the forceIndexReload setting

Screenshots

Platform App
All

Back to Top

Test the Sample

Apart from exploring the sample code base in GitHub, you can also clone and run the sample in your preferred AppBuilder client.

In-Browser

With the AppBuilder in-browser client, you can develop hybrid and NativeScript cross-platform mobile apps from your browser. You can use the in-browser client at https://platform.telerik.com.

Clone the sample

  1. Click the button at the top of this document.
  2. Provide your login credentials, if prompted.

Run the sample

  1. Run in the companion app.
  2. Deploy on device via QR code.

Back to Top

Windows

With the AppBuilder Windows client, you can develop hybrid and NativeScript cross-platform mobile apps from your Windows desktop. You can download and install the Windows client from http://www.telerik.com/appbuilder/windows-client.

Clone the sample

  1. Verify that the AppBuilder Windows client is running and you are logged in the Telerik Platform in the account in which you want to develop your application.
  2. In the dashboard, click Samples and select Hybrid.
  3. From the Workspace drop-down menu, select the workspace in which you want to develop your application.
  4. Select Advanced APIs.
  5. Select LiveSync.
  6. (Optional) Rename the project.
  7. Click Clone.

Run the sample

With the AppBuilder Windows client, you can quickly test your apps on device, in the simulator or in the native emulators.

  1. Run in the companion app.
  2. Run in the native emulators.
  3. Deploy on device via QR code.
  4. Deploy via cable connection.

Back to Top

Visual Studio

With the AppBuilder extension for Visual Studio, you can develop hybrid and NativeScript cross-platform mobile apps from Microsoft Visual Studio. You can download and install the extension from http://www.telerik.com/appbuilder/visual-studio-extension.

Clone the sample

  1. Verify that the AppBuilder extension for Visual Studio is running and you are logged in the Telerik Platform in the account in which you want to develop your application.
  2. Select AppBuilderGet Sample.
  3. Select Hybrid.
  4. Select Advanced APIs.
  5. Select LiveSync.
  6. (Optional) Rename the project.
  7. Click Get.

The extension for Visual Studio copies the sample files locally. The extension creates a new solution and project and loads them.

Run the sample

With the AppBuilder Windows client, you can quickly test your apps on device, in the simulator or in the native emulators.

  1. Run in the companion app.
  2. Run in the native emulators.
  3. Deploy on device via QR code.
  4. Deploy via cable connection.

Back to Top

CLI

With the AppBuilder command-line interface, you can develop hybrid and NativeScript cross-platform mobile apps from the command line. You can learn how to add the AppBuilder commands to your command line from http://www.telerik.com/appbuilder/command-line-interface.

Clone the sample

  1. Verify that a command prompt is running and you are logged in the Telerik Platform in the account in which you want to develop your application.
  2. To list the available samples, run the following command.

    appbuilder sample
    
  3. Run the clone command for the sample as listed by appbuilder sample.

    appbuilder sample clone livesync
    

The AppBuilder command-line interface shows the following message: Successfully initialized project in the folder!

Run the sample

With the AppBuilder command-line interface, you can quickly test your apps on device, in the simulator or in the native emulators.

  1. Run in the companion app.
  2. Run in the native emulators.
  3. Deploy on device via QR code.
  4. Deploy via cable connection.

Back to Top

Limitations

  • You cannot run this sample in the device simulator.
  • 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 companion 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 AppBuilder extension for Visual Studio 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, from the main menu bar, select AppBuilderSynchronize ‹project name› with Cloud.
  • If you are using the AppBuilder 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
  • Executing window.livesync.sync() in your onDeviceReady event might cause your app to enter an endless loop of synchronizing changes and reloading.

Back to Top

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.