rubystarashe / nuxt-vuex-localstorage

MIT License
161 stars 18 forks source link

Store localStorage into phone's native storage using Cordova plugin / third-party plugin #16

Closed sts-ryan-holton closed 3 years ago

sts-ryan-holton commented 5 years ago

Hi, I'm using the nuxt-vuex-localstorage plugin in my Nuxt JS 2.9.2 application to build a Hybrid app using Cordova. This plugin works great, however, data is wiped from the app whenever the app is updated via the app store/play store.

I'm using the Cordova Nativestorage Plugin now to save data in the phone's storage via two methods, one to save data, the other to retrieve data like so:

methods: {

  storeData() {
    var obj = {
      name: 'John',
      age: 30
    }
    NativeStorage.initWithSuiteName("beacon");
    NativeStorage.setItem("reference_to_value", obj, () => {
      alert("SUCCESS");
    }, () => {
      alert("ERROR");
    });
  },

  getData() {
    NativeStorage.getItem("reference_to_value", (value) => {
      alert(value.name);
    }, () => {
      alert("ERROR");
    });
  }

}

I'm wondering how could I store the contents of store/localStorage.js into this Nativestorage plugin in order to access the data native to the device.

For the most part, the state of my store/localStorage.js file is as follows:

export const state = () => ({
  pageTitle: 'Beacon',
  dataUrls: [],
  intervalData: [],
  settings: [],
  experimentalFeatures: [],
  customAlertSeen: false,
  user: null,
  account: null
})

Could anyone help? Or if anyone has got a similar issue?

rubystarashe commented 4 years ago

The same issue occurs for some electron apps that use internal server. This is because the internal port address changes every time it is executed. This could be solved by fixing the port address.

So, You have to find the storage's application distinguishing point. It can be manifest data or app name. One of the data that can change with each update.

Or you can use app storage instead of localStorage.