Skip to main content
Known Participant
June 1, 2013
Question

SharedObject fail on iOS

  • June 1, 2013
  • 1 reply
  • 1234 views

Hi.

When I published a update to my quiz app, most of the devices of users stopped saving their score.

Some people even report that every time they open the app, they have to start all over again.

The reports are from people contacting me on e-mail and twitter.

It seems very random, some iPhone 5´s, some iPhone 4s´, and some iPad´s.

I am using iPhone 4s and iPad 4 to test my applications, and everything works fine on my devices.

It started to happen once I updated my app from v1.5 to v1.6, changing AIR version from 3.4 to 3.6 because of the required iPhone 5 support as of May 1.

Any ideas as to how I can debug this error?

Regards,

Skogemann

This topic has been closed for replies.

1 reply

Adobe Employee
June 3, 2013

There were some changes for sharedObject in AIR 3.5, please see the link http://blogs.adobe.com/airodynamics/2012/12/10/changed-behavior-of-shared-object-on-ios-in-air-3-5/ , hope this will help.

Regards,

Nimit

Known Participant
July 8, 2013

I have read your post.

It is weird, since I never published a version using Air 3.5.

Anyway, players who have had the game since before the issue are reporting that every time they quit the app, their progress is lost again. The only thing that fixes the consistent saving of the progress is to uninstall and install app again.

Any idea how I can restore their previous progress?

Regards, skogemann

Projectitis
Inspiring
July 8, 2013

Hi Skogemann - the fix is a little complicated, but not too bad.  We ran into the same issue with our game Rescue 1 and fixed it by manually copying the raw sharedObject (.sol) files using file system commands within AS3.

Firstly you need to understand the problem, and know what the sharedObject file (.sol) is called (and the path to it) in the old app and the new app.  The best thing to do is to install the AIR3.5 version and then use iFunBox to browse the application file structure and find the exact path to the shared object.  Then uninstall that and install the AIR3.7 (or whatever) version and do the same.

This needs to be done BEFORE loading your shared object:

Check if the 'old' file exists and no 'new' file exists yet.  If this is the case, copy the old file to the new file (renaming it, basically) and delete the old one.

// if the AIR3.5 shared object exists and the AIR3.7 shared object does not then we move the AIR3.5 sol to where

// we expect to find the AIR3.7 sol so we can continue to use the existing game data

var fileTo:FileReference = File.applicationStorageDirectory.resolvePath("#SharedObjects/Rescue 1.swf/savedData.sol");

var fileFrom:File = File.applicationStorageDirectory.resolvePath("#SharedObjects/Rescue1.swf/savedData.sol");

if(fileFrom.exists) {

     if(!File(fileTo).exists) {

          fileFrom.copyTo(fileTo);

     }

     fileFrom.deleteFile();

}

Then you can safely open your sharedObject and it should use the old one (which is now the new one).

Note that in our case AIR3.5 used a key from the application.xml file that contained a space, and in other versions of AIR it used a key that did not contain a space, so the app couldn't find and load the sharedObject.

Another tip is that as long as your existing users haven't uninstalled the app, the old saved data will still be there, so you can do a new update and restore their data - but be careful!  If they have new data you will overwrite it using the above code and they will lose their new data!  This is what we actually did:

1) If the 'old' file exists, but the new one does not, copy the old file to the new location.

2) If the 'old' file exists AND the new one also exists, copy the old one to the same folder as the new one, but with a different name.  Now open both shared objects and copy data from one to the other (we compared all data and copied the biggest values - e.g. highest score, most coins etc).  You'll have to decide which data to keep based on your game.

3) If the 'old' file does not exists, no need to do anything.