Offline storage Sync

12 posts, 0 answers
  1. Chris
    Chris avatar
    15 posts
    Member since:
    Jun 2011

    Posted 05 Nov 2014 Link to this post

    Hi,
    I was after some clarification on using the Kendo datasource and the Everlive dialect in offline mode.
    If the datasource is set to autoSync: true when i move the datasource back to online will the datasource automatically sync the changes with the backend services or do i need to call the sync method?

    Thanks Chris

  2. Anton Dobrev
    Admin
    Anton Dobrev avatar
    539 posts

    Posted 05 Nov 2014 Link to this post

    Hi Chris,

    Thank you for your question.

    The data source will sync the changes from the offline state once its online() method is called. Consider the following example for simplicity - the comments in the code will outline the behavior.

    dataSource.fetch(function() {
        // go in offline mode
        dataSource.online(false);
     
        // add item to the data source
        var model = dataSource.add();
        model.Id = "1";
        model.Text = "My text";
     
        // go online - the new data is posted immediately
        dataSource.online(true);
    });

    The above data source is not configured to use auto sync, it uses the simplest configuration. On the other hand, the autoSync configuration will try to connect to the server once there are any changes in the data source. If you'd like to have more control of the data synchronization you may consider syncing the data yourself by calling the sync() method or by toggling the online state.

    Let me know if this is helpful for you and if you have further questions.

    Regards,
    Anton Dobrev
    Telerik
     

    Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

     
  3. David Gerding
    David Gerding avatar
    44 posts
    Member since:
    Sep 2005

    Posted 23 Nov 2014 in reply to Anton Dobrev Link to this post

    Hi Anton,
    I, too, am really interested in the offline sync/storage in the DataSource update for KendoUI.  Has anyone done a demo app yet that can show a common implementation? I've got my own approach that syncs to Sqlite on the client - but it's pretty rough around the edges.  What are the storage limitations with the offline datasource?  Is it using localstorage?  Any clues, details or working examples in the mobile context greatly appreciated.  

    Thanks,
    Dave Gerding
  4. Anton Dobrev
    Admin
    Anton Dobrev avatar
    539 posts

    Posted 25 Nov 2014 Link to this post

    Hello,

    I made a simple example to showcase the feature based on our Grocery List interactive tutorial. In the initialization of the app its subscribes to the online/offline events and toggles the data source online state accordingly.

    You can try the sample by importing it in your favorite AppBuilder client and switching between the network connections available in the simulator. They will simulate the Cordova Networik Connection API.

    Note that the project should be connected to a Backend Services project. The data source is configured to work with a Content Type named "Groceries", but you can set your own content type name.

    @Dave

    I hope that this article will answer your questions.

    Regards,
    Anton Dobrev
    Telerik
     

    Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

     
  5. David Gerding
    David Gerding avatar
    44 posts
    Member since:
    Sep 2005

    Posted 25 Nov 2014 in reply to Anton Dobrev Link to this post

    Anton, 
    Great!  Thanks as always for your help.

    Dave Gerding
  6. Chris
    Chris avatar
    15 posts
    Member since:
    Jun 2011

    Posted 28 Nov 2014 in reply to Anton Dobrev Link to this post

    Wher is the sample app you created. I would like to take a look at this.
    Chris
  7. Anton Dobrev
    Admin
    Anton Dobrev avatar
    539 posts

    Posted 01 Dec 2014 Link to this post

    Hello,

    Seems that the attached file in the thread is not visible. Here is the link to the repo in GitHub.

    Also, I suggest reading the following series of blog posts in order to handle better the offline/online state of the data source and examine the Cordova Network Connection API.

    Let me know if you have further questions.

    Regards,
    Anton Dobrev
    Telerik
     

    Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

     
  8. Marlon
    Marlon avatar
    16 posts
    Member since:
    Jul 2013

    Posted 01 Dec 2014 Link to this post

    I asked this question during the presentation but had to drop off and never heard if it was answered. If this offline funcitonality if used in a hybrid app as you demo, how will this persist if the app is killed? As far as I know, if the app is terminated (at least on iOS) the browser's localStorage would be lost as well. 

  9. Anton Dobrev
    Admin
    Anton Dobrev avatar
    539 posts

    Posted 04 Dec 2014 Link to this post

    Hello,

    @Marlon
    By default, the data source uses the localStorage API for the data stored offline.

    The data in the local storage is persisted between starts/stops of the app, also on iOS devices. However, the data in the local storage could not be persisted between installations. 

    Please, let me know if you have questions. 

    Regards,
    Anton Dobrev
    Telerik
     

    Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

     
  10. Marlon
    Marlon avatar
    16 posts
    Member since:
    Jul 2013

    Posted 08 Jan 2015 in reply to Anton Dobrev Link to this post

    Anton,

    My question wasn't regarding installations of the app.  I understand that localStorage is cleared if the app is removed . I'm asking about the app being closed  - not just suspended. Are you saying that the localStorage will be maintained if the app is completely closed? (on iOS this could be done if the app crashes or if the user chooses to force the app to close via the App Switcher)
  11. Chris
    Chris avatar
    15 posts
    Member since:
    Jun 2011

    Posted 08 Jan 2015 in reply to Marlon Link to this post

    Hi,
    I have found that if the app is completely closed on iOS then the local storage is lost.
    We are looking at way of using sqlLite as a means of persisting the data between shut downs etc. It would be nice if persistence be built into the datasource.

    Chris
  12. Anton Dobrev
    Admin
    Anton Dobrev avatar
    539 posts

    Posted 13 Jan 2015 Link to this post

    Hi,

    @Marlon
    Based on my observations and tests the localStorage on iOS using Cordova 3.5 is persistent between app starts/stops. Also, it could be persisted between app installations if the iCloud sync is enabled on the device and a backup of the device has been done.

    What I am guessing here is that Chris refers to the Kendo Data Source in offline mode that uses localStorage. The Data Source (the "vanilla" one) is configured to search in the local storage if it is set to offline, so if there is any data stored, it will be used by the data source. It appears that the data source will initially try to load a resource from the server, even if there is no internet connection available at the moment and given that the items are stored in the localStorage. Could you please specify, is this the case here?

    Indeed, depending on the requirements, you can save the data using the SQLite plugin in AppBuilder.

    Please, let me know if you have any questions or suggestions.

    Best regards,
    Anton Dobrev
    Telerik
     

    Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

     
Back to Top