return stored Background Data during background process

Hello,

I'm attempting to read the data that has been sent to the app but not delivered during background process execution.

var backStack = Background.getBackgroundData();

Using the latest entry I think I can make the decision to grow the stack or exit.

I'm assuming that backStack is an array,

Is this correct?

Also, can this be tested in the simulator? Can you close the app and leave the background service running?

Thanks,

Joe
  • There is only one saved background data value. If the data has not yet been passed to the main application when Background.exit(data) is called, the old background data value overwritten. You can save a history of background data by reading the old data and merging it with the new data in your background process.

    If you want to save an array of the last several runs, you could call getBackgroundData() you could do something like this:

    var exitData = Background.getBackgroundData();
    if( backStack == null ) {
    exitData = [newData];
    } else if ( exitData.size() < MAX_DATA_RECORDS ) {
    exitData = exitData.add(newData);
    }
    Background.exit(exitData);