Shaun7189763
Posts: 0
Joined: Sun Oct 26, 2014 8:16 am

localStorage cleared on app restart

Hello,

I have set a localStorage value called 'token' that my application needs to get as soon as it is launched by the user.

The intended behaviour :

if 'token' is set = navigate directly form startScreen to another page.
if 'token' is undefined/null = stay on startScreen

The process works well with the buider's Test function (in the browser).

However in the Appery.io Tester, or on the exported App (apk) if the user closes the App (I mean totally with app swipe out of screen), 'token' is lost and becomes 'undefined'.

I thought localStorage is persistent and should not be cleared even when the application is closed. Am I doing something wrong ?

Thanks for your help.

Shaun

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

localStorage cleared on app restart

Hello,

localStorage store value even after exit from the app. Please check where in code you change it. Could you check are there any errors in console?

Shaun7189763
Posts: 0
Joined: Sun Oct 26, 2014 8:16 am

localStorage cleared on app restart

Hello Sergiy,

There are no error in the console.

I have made a few changes and it is now working in the Apperyio tester but not with the proper apk.

When the user signs in successfully (on success) the app runs the following javascript :

localStorage.setItem('token', data.sessionToken);

I have the localstorage variable ready :

Image

When I exit the app, and open it again in the Apperyio Tester, I can see the localstorage value in a label component (local_data) I have created for this purpose :

I call the localstorage on page load :

Apperyio("local_data").text(localStorage.getItem('token'));

Image

However, with the proper app (apk), the localstorage is empty :

Image

What am I doing wrong ? Thanks in advance for your help.

Shaun

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

localStorage cleared on app restart

Hi Shaun -

Which Android version you're using for testing?

As you already noticed, it looks like there is a bug in Android 5.0 -- https://getsatisfaction.com/apperyio/...

Shaun7189763
Posts: 0
Joined: Sun Oct 26, 2014 8:16 am

localStorage cleared on app restart

Hello Illya,

I'm testing on Android 5.0

Best regards

Return to “Issues”