You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by "Christian Hemker (JIRA)" <ji...@apache.org> on 2012/09/25 15:56:07 UTC

[jira] [Updated] (CB-1535) LocalStorage is not saved after first App launch on iOS 6

     [ https://issues.apache.org/jira/browse/CB-1535?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Christian Hemker updated CB-1535:
---------------------------------

    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. 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. Now you can restore the value (Everything runs fine from now on)

Simple Javascript Test code to reproduce with index.html

{code}
<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>

{code}


  was:
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. 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. Now you can restore the value (Everything runs fine from now on)

Simple Javascript Test code to reproduce with index.html

<code>
<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>

</code>


    
> LocalStorage is not saved after first App launch on iOS 6
> ---------------------------------------------------------
>
>                 Key: CB-1535
>                 URL: https://issues.apache.org/jira/browse/CB-1535
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: iOS
>    Affects Versions: 2.1.0
>         Environment: iOS 6.0 - iOS Simulator
> iOS 6.0 - iPad 2
>            Reporter: Christian Hemker
>            Assignee: Shazron Abdullah
>
> 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. 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. Now you can restore the value (Everything runs fine from now on)
> Simple Javascript Test code to reproduce with index.html
> {code}
> <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>
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira