Apache Cordova
  1. Apache Cordova
  2. CB-1535

LocalStorage is not saved after first App launch on iOS 6

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.0
    • Fix Version/s: None
    • Component/s: iOS
    • Labels:
      None
    • Environment:

      iOS 6.0 - iOS Simulator
      iOS 6.0 - iPad 2

      Description

      1. Save a value in window.localStorage after a fresh install of the App in Simulator or iOS Device.
      2. Stop the App while running in Background.
      3. Restart the App and Restoring the value from window.localStorage is not possible (Error)
      4. Save a new value in window.localStorage
      5. Stop the App while running in Background.
      6. Restart the App and now you can restore the value (Everything runs fine from now on)

      To reproduce create a sample project with the "create" script.
      Put this Javascript into index.html or use the attached index.html.

      The Parameter BackupWebStorage is not changed.
      BackupWebStorage=YES

      <script type="text/javascript">
                  document.addEventListener("deviceready", onDeviceReadyToSave, false);
                  
                  function onDeviceReadyToSave() {
                      
                      var item = window.localStorage.getItem("key");
                      var message = "deviceready localStorage.getItem('key')="+item+" localStorage.length="+window.localStorage.length;
                      
                      console.log( message);
                      alert(message);
                      
                      if( item == null){
                          console.log("localStorage.getItem('key') is '"+item+"'");
                          item = "";
                      }
                      item = item + "value";
                      
                      window.localStorage.setItem("key", item);
                      console.log("calling localStorage.setItem('key', '"+item+"')");
                      
                      var value = window.localStorage.getItem("key");
                      console.log("verified localStorage.getItem('key')="+value);
                  }
              </script>
      
      
      1. index.html
        3 kB
        Christian Hemker

        Activity

        No work has yet been logged on this issue.

          People

          • Assignee:
            Michal Mocny
            Reporter:
            Christian Hemker
          • Votes:
            2 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development