0

I use SharedObject in AIR to storage some data in IOS App.

when I set UIApplicationExitsOnSuspend to true, shared objects work fine, it means if I remove it from Fast App Switcher(Fast App Switcher appears by double clicking on home button), and then run the app again, SharedObject with my data is still there.

But if I set UIApplicationExitsOnSuspend to false and remove app from Fast App Switcher and then run it again, my SharedObject is empty.

The problem is I need to use UIApplicationExitsOnSuspend false, but I also need to storage SharedObject all the time, not even when it works in the background.

Thank you.


UPD: some code

this is constructor of the project main class:

public static var so:SharedObject;
public function Main():void
{

so = SharedObject.getLocal("MyApp");
}

and then i use it like this

if (!Main.so.data.names) {
Main.so.data.names = [];
}
Main.so.data.names.push(someNewName);

while app is working in background, it works fine, all changes saves. but if i kill app in Fast App Switcher, and then run again, debugger shows Main.so.data contains nothing

  • 1
    Can you post code where SharedObject is loaded and saved. –  Feb 05 '13 at 23:50
  • @LeeBurrows ok, just updated my question – user1622036 Feb 06 '13 at 12:44
  • where are you calling flush() ? –  Feb 06 '13 at 13:07
  • @LeeBurrows actually I didn't call flush(), becouse I knew that data was saved, becouse when I puted another name in array, the array was not empty(debugger showed it). I tried to call flush() now - just after last code snippet - still have the same problem - shared is alive only while app works in background. – user1622036 Feb 06 '13 at 14:23
  • 1
    array not being empty doesnt mean data was saved (to disk), just that its 'saved' to memory. i believe that (for iOS) flush() does not automatically get called when app closes. I always call flush manually with SO objects. –  Feb 06 '13 at 15:12
  • I would also look at your "ACTIVATE" event handler - are you doing something when the app gains or regains focus that might be clearing the SO? – Tom Auger Oct 21 '14 at 16:07

1 Answers1

0

I ran into the EXACT same problem on AIR for iOS. Using EncryptedLocalStore instead of ShareObject seems to solve the problem.

Here is a link on how to save and retrieve an array using EncryptedLocalStore. Notice the link has a typo - 'EncryptedLocalStorage', change it to 'EncryptedLocalStore' instead - Is it possible to store an Array into an EncryptedLocalStore item? AIR

Community
  • 1
  • 1
YUFU
  • 21
  • 3