localStorage on iPad is reset from time to time

1

I have a game that I have made that I save some data in "localstorage", but apparently the iOS operating system does a cleaning from time to time and you never know when this cleaning will be.

This is a serious problem for my game because it has to work offline without internet. If there is no solution to this, it has occurred to me that I could make the game save the data in the iPad notes app or in the pages or in the keynote.

Does anyone have a better solution to this problem?

The game has a Leaderboard that keeps the top 5 in local and then in a hidden screen the administrator can see all those who have played, that screen is a simple table:

I have made it possible when you have an internet connection to send it by e-mail, only that you will not always have it and I want you to save it somewhere, even if it is a third-party application.

    
asked by Marc Lemien 11.05.2016 в 11:48
source

2 answers

1
  

I have a game that I have made that I save some data in "localstorage", but apparently the operating system ios from time to time makes a cleaning and you never know when this cleaning will be.

It has never happened to me, it seems a bit strange, however your application should not depend on the localStorage (or sessionStorage), they are very useful tools but there are several ways in which it can be cleaned / deleted not only in Safari, but also in other browsers.

  

This is a serious problem for my game because it has to work offline without internet. .. it occurred to me that I could make the game save my data in the iPad notes app or in the pages or in the keynote ...

From the browser It is not possible to interact with other applications to read / write data. It's a security issue. You need another approach.

The most viable option would be to use a mixture of local Storage and Internet storage by synchronizing the data when there is a connection, and in the case of losing (or manually cleaning) the data from the local Storage, the downloads of the copy on the Internet. Of course, at that moment the webapp should be connected to make the download ..

    
answered by 14.05.2016 / 12:21
source
2

There is no problem in saving data that remains indefinitely and without the system deleting it. The important thing is to keep them in the correct folder. As a summary, the available folders are:

  • /Documents : here all data that can not be recreated by other means or content generated by the user must go. ex: Word Document
  • /Library/Caches : here everything that can be regenerated without user intervention. ex: image cache
  • /tmp : Temporary files for the operation of the app that you should disappear when you close the app.

From here, if in your case they are progress data (for example) you should save it in /Documents since it will also be a copy in iCloud .

You have more information here .

    
answered by 11.05.2016 в 15:23