Quantcast
Channel: Adobe Community: Message List
Viewing all articles
Browse latest Browse all 92406

iOS 8 - FileStream throwing error 2038 on open for write?

$
0
0

Hey all,

 

Going through iOS 8 compatibility checks with our Adobe AIR app (tested with AIR 13 and AIR 14), I'm noticing changes to file storage.

In short, my code has always been as follows for simply storing a player profile file (matching iOS documentation for as fas as I know: File System Programming Guide: File System Basics). And this has worked well to prevent purges when the device is low on storage space as well as keeping the data there when updating the app.

 

This code only seems to work for iOS 4 to iOS 7:

var storagePath:File = new File(File.applicationDirectory.nativePath + "/\.\./Documents");

try
{
     var targetFile:File = storagePath.resolvePath("profile.bin");     var stream:FileStream = new FileStream();     stream.open(targetFile, FileMode.WRITE);     stream.writeBytes(<byteArray here>, 0, 0);     stream.close();
}
catch (err:Error)
{     <informs user something went wrong, retries, etc. basic error handling>
}

 

Running this on iOS 8 will always throw a SecurityError (#2038) from stream.open.

Now, we can still save data and fix this by replacing the first line by:

var storagePath:File = new File(File.applicationStorageDirectory.nativePath);

 

But, this leaves me with a few things, in order of descending importance:

1) Reading something like this makes me scared as our game has a large amount of daily players: "I’m using applicationStorageDirectory to store files. The problem is those files get deleted when the user updates his app…" (AIR App Compliance with Apple Data Storage Guidelines, last comment)

2) What has changed in the iOS 8 file system that suddenly makes my original code fail? Apple developer documentation is still outlining this should be valid. Is this a possible AIR bug?

3) I assume I need to set "don't backup" flags on the files when saving to the appStorageDir?

4) Is anyone else running into this?

 

Thanks in advance!


Viewing all articles
Browse latest Browse all 92406

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>