简体   繁体   English

Adobe AIR SharedObject-Android / iOS-找不到更新

[英]Adobe AIR SharedObject - Android/iOS - On update not found

As the title states, my user's on iOS and Android are reporting their save data has been deleted when I push an update to the respected storefronts. 如标题所示,当我向受关注的店面推送更新时,我的iOS和Android用户报告他们的保存数据已删除。 The game saves and restores data properly on application load and exit. 游戏会在应用程序加载和退出时正确保存和恢复数据。 I have not changed any save information locations or package names... Just mere bug fixes, build, push. 我没有更改任何保存信息的位置或程序包名称...仅是错误修复,构建,推送。

Any clarification would be helpful, or proposed redundant data backup scheme's I should pursue to ensure the end-user experience is from henceforth not affected negatively. 任何澄清都将是有帮助的,或者建议采用冗余数据备份方案以确保从此以后不会对最终用户体验造成负面影响。 I would also like to understand better how I can test this as a release package is not allowed to update a market installed application. 我还想更好地了解我如何测试此功能,因为不允许发布包更新市场安装的应用程序。

var so:SharedObject = SharedObject.getLocal("storage"); 
var u:User;
if(so.data != null){
    u = so.data.user;
}

trace("Loading application...");

if(u != null){
    trace("LOADING SAVE DATA");
    user = u;
}else{
    trace("NO SAVE DATA EXISTS");
    user = new User();
}

I have discovered the cause of this issue and it seems that Adobe has identified and fixed the issue as well (as of AIR 3.5). 我已经发现了此问题的起因,并且看来Adobe也已经确定并解决了该问题(从AIR 3.5开始)。 https://bugbase.adobe.com/index.cfm?event=bug&id=3347676 https://bugbase.adobe.com/index.cfm?event=bug&id=3347676

SharedObjects are stored within a directory named according to the SWF used by your application, so if your application is running off "myApp.swf" the SharedObject will be stored in a directory "myApp". SharedObjects存储在根据您的应用程序使用的SWF命名的目录中,因此,如果您的应用程序运行在“ myApp.swf”之外,则SharedObject将存储在目录“ myApp”中。 If you change the name of this SWF (ie the corresponding XML build sheet configuration file for your AIR project) any subsequent builds will store their SharedObjects in a new location. 如果更改此SWF的名称(即AIR项目的相应XML构建表配置文件),则任何后续构建都将其SharedObjects存储在新位置。

The issue described in this bug was specifically denoted for iOS, wherein the application was not storing the SharedObject in the corresponding SWF location as described above but in a separate location denoted by the "filename" attribute in your project's XML build sheet. 此错误中描述的问题专门针对iOS表示,其中应用程序未将SharedObject如上所述存储在相应的SWF位置中,而是存储在项目的XML构建表中由“文件名”属性表示的单独位置中。

I have also discovered that Adobe does indeed condone the use of a SharedObject for persistent storage on a mobile platform. 我还发现Adobe确实同意使用SharedObject在移动平台上进行持久存储。

I have developed a simple backup for future version save redundancy in case future updates fail to persist the SharedObject. 我为将来的版本保存冗余开发了一个简单的备份,以防将来的更新无法持久化SharedObject。

/** the last timestamp a deep save was completed */
private var mLastSave:Number = -1;


/**
 * save the state of the globals object and all of its
 * sub objects.
 * @warning
 * all objects must implement variables in a "public" state.
 * Private variables are not saved within the persistance manager
 */
public function save():void{
    var so:SharedObject = SharedObject.getLocal("storage");
    so.data.user = user;
    so.flush();
    saveDeep();
}


/**
 * Save the SharedObject to denoted mobile applicationStorageDirectory.
 */ 
public function saveDeep():void{
    // save on first application save or after
    // every 5 minutes
    if(mLastSave == -1 || mLastSave < getTime() + 300000){
        mLastSave = getTime();

        var file:File = File.applicationStorageDirectory.resolvePath("userSave");
        var fileStream:FileStream = new FileStream(); 
        fileStream.open(file, FileMode.WRITE);
        var ba:ByteArray = new ByteArray();
        ba.writeObject(user);
        fileStream.writeBytes(ba);
        fileStream.close();
    }   
}


/**
 * Load the application from the SharedObject be default
 * if the SharedObject DNE attempt to load from the 
 * applicationStorageDirectory, if neither exist
 * create new User object
 */ 
public function load():void{

    registerClassAlias("user", User);

    // Create/read a shared-object named "userData"
    var so:SharedObject = SharedObject.getLocal("storage"); 
    var u:User;
    if(so.data != null){
        u = so.data.user;
    }

    trace("Loading application...");

    if(u != null){
        trace("LOADING SAVE DATA");
        user = u;
    }else{
        trace("NO SAVE DATA EXISTS");
        var file:File = File.applicationStorageDirectory.resolvePath("userSave");
        if(file.exists){
            trace("Found userSave backup -attempting to load");
            var fileStream:FileStream = new FileStream(); 
            fileStream.open(file, FileMode.READ);
            var ba:ByteArray = new ByteArray();
            fileStream.readBytes(ba);
            fileStream.close();
            try{
                user = (ba.readObject() as User);
            }catch( e : EOFError ){
                trace("SharedObject did not exist, attempted userSave load, failed");
            }
        }else{          
            user = new User();
            trace("created New user...");
        }
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM