localStorage contents not there on first run

914 views
Skip to first unread message

Björn Nilsson

unread,
Jul 3, 2010, 5:11:57 AM7/3/10
to phonegap
Hi,

I was wondering if anyone else but me have experienced this problem:

After an application is updated on device (for example from launching
on device in xcode or from the itunes app store), the previously saved
data, saved using localstorage API, is not available.

When shutting down the app and launching it again, everything is there
again.

The problem only shows itself on first launch, its almost like the app
is runinng in a different "storage context/containter" on the first
run.

/Björn

Björn Nilsson

unread,
Jul 4, 2010, 5:04:10 PM7/4/10
to phonegap
I only have this problem if this is present in my -Info.plist:

<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>

If I instead have the default:

<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>

Everything is OK and the values are read the first launch also.

Very strange stuff going on here, that these settings should affect
local storage behavior.

(The reason Im setting UISupportedInterfaceOrientations key like this
is to force landscape only, as per comment to bug
http://phonegap.lighthouseapp.com/projects/20116-iphone/tickets/57)

Björn Nilsson

unread,
Jul 7, 2010, 5:16:23 AM7/7/10
to phonegap
I found the solution to this finally, and I will document it here if
anyone else is hit by this:

in PhoneGapViewController.m, willRotateToInterfaceOrientation
function:

[webView stringByEvaluatingJavaScriptFromString:[NSString
stringWithFormat:@"navigator.orientation.setOrientation(%f);", i]];

Comment out the above call, and the problem is gone. I have no idea
why this is the case, but works for me.

On Jul 4, 11:04 pm, Björn Nilsson <bni....@gmail.com> wrote:
> I only have this problem if this is present in my -Info.plist:
>
> <key>UISupportedInterfaceOrientations</key>
> <array>
>     <string>UIInterfaceOrientationLandscapeRight</string>
>     <string>UIInterfaceOrientationLandscapeRight</string>
>     <string>UIInterfaceOrientationLandscapeRight</string>
>     <string>UIInterfaceOrientationLandscapeRight</string>
> </array>
>
> If I instead have the default:
>
> <key>UISupportedInterfaceOrientations</key>
> <array>
>         <string>UIInterfaceOrientationPortrait</string>
> </array>
>
> Everything is OK and the values are read the first launch also.
>
> Very strange stuff going on here, that these settings should affect
> local storage behavior.
>
> (The reason Im setting UISupportedInterfaceOrientations key like this
> is to force landscape only, as per comment to bughttp://phonegap.lighthouseapp.com/projects/20116-iphone/tickets/57)
Reply all
Reply to author
Forward
0 new messages