Jump to content

LocalStorage + Cocoon WebView+


Batzi
 Share

Recommended Posts

Hello guys,

I'm having issues with the iOS version of my app. LocalStorage is not working and I am not sure if it's a Cocoon problem or an iOS problem given it works great on Android.

It seems that the data being stored is cleared after I quit the app.

My app (Phaser) is packaged using Cocoon (Webview+).

Any of you having localStorage problems on iOS? Are you using something other than Cocoon to package the app?

Thank you

Link to comment
Share on other sites

I have never used local storage in a game with cocoon, but I have used in another ios app that used a web view and it also cleared the local storage when I exited the app.

If you are doing mobile games that need persistence, instead of having to deal with local storage, you can instead write a file to the device with this plugin: https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-file/

 

Link to comment
Share on other sites

Sadly, iOS clears localStorage whenever it feels like it (which appearantly is always). As Bruno suggested there are plugins that allows you to overcome this issue. 

Where cordova-plugin-file is a nice solution, it requires you to do some extra work like setting up a json to write to the file. Instead, you could also go for cordova-plugin-nativestorage that expose an API similar to localStorage.

I've also created a localStorage wrapper for Phaser that allows for Storage Adapters (localStorage and NativeStorage included) that easily allows you to switch storages and still keeping the same api

Link to comment
Share on other sites

localStorage  is not working in some ios device, it should be fine in >ip6, it is weird in some old phone like iphone 5. maybe it is related to the configuration of your safari. take care of it, use try to access localstorage otherwise it might raise error at some point.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...