pilar1347
pilar1347

Reputation: 188

localStorage no longer working in iOS 7 WebView

I am developing an HTML5 web app that is run from a WebView inside an iOS app. Once the users upgrade to iOS7, localStorage stops working and the app (which uses jQuery/jQuery Mobile) just shows the spinner.

I've run some tests using Modernizr and it does not detect support for localStorage in the WebView within the app. This is strange, because it works fine in Safari on the iPad with iOS7.

Has anyone else run into this issue or have a magical fix? The only client-side web storage API that seems to work is Web SQL in iOS7 WebView, and if I can help it I'd rather not have to use that.

Upvotes: 2

Views: 9326

Answers (2)

russau
russau

Reputation: 9088

Try out this cookie policy setting from the gist: https://gist.github.com/steveriggins/6652508

[[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways];

Upvotes: 2

Andrew
Andrew

Reputation: 11

Since upgrading to iOS7 everything stored in localStorage seems to be wiped when the web page reloads.

<script>
function supports_html5_storage() {
  try {
return 'localStorage' in window && window['localStorage'] !== null;
  } catch (e) {
    return false;
  }
}
if(supports_html5_storage()){
 rString=localStorage.getItem("SerialID");
 alert("We have localStorage support "+rString);
 if(rString) if(rString.length>0) alert("SerialID is present");
} else {
 alert("We do not have localStorage support");
}
</script>

Upvotes: 1

Related Questions