localStorage, iOS, automatic deletions & best strategy

Hi there,
I am using $localstorage factory to store app specific data as below:


angular.module('ionic.utils', [])

.factory('$localstorage', ['$window', function($window) {
  return {
    set: function(key, value) {
      $window.localStorage[key] = value;
    get: function(key, defaultValue) {
      return $window.localStorage[key] || defaultValue;
    setObject: function(key, value) {
      $window.localStorage[key] = JSON.stringify(value);
    getObject: function(key) {
      return JSON.parse($window.localStorage[key] || '{}');

While this generally works well, on iOS some folks have reported the data gets deleted every time they run. On researching this it seems its a known problem and that iOS does delete if disk space is low.

So I need to implement a least intrusive strategy to make sure the rest of my app using $local storage does not need to change and any change I need goes into $localstorage factory.

Any thoughts?

  1. I saw localForage --> but that seems to suffer from the same problem
  2. possibility to back data to iCloud/Google Cloud
  3. Whatever option I use needs to support iOS/Android/regular Desktop apps (I am using Electron)