Update Parse.com Database OnApplicationQuit

I need to update the Database on Parse.com when a user quits the game. I have the inventory class check OnApplicationQuit() and when it does, it calls a SaveInventory function which saves to the Parse.com Database.

I know that the SaveInventory function works, if I call that at any point during the normal game, it saves as it should. When OnApplication is Called, Every Debug.Log in SaveInventory is called as it should be. Does anyone know how I can update the database when a user quits.

Here is my SaveInventory function:

public void SaveInventory(DictionaryOfStringAndInt inventory) {
		Debug.Log("Save Starting");
		myInventory = inventory;
		inventoryData.SaveAsync().ContinueWith(t => {
			List<string> slots = new List<string>() {
				"slot01", "slot02", "slot03", "slot04", "slot05", "slot06", 
				"slot07", "slot08", "slot09", "slot10", "slot11", "slot12", 
				"slot13", "slot14", "slot15", "slot16", "slot17", "slot18", 
				"slot19", "slot20"
			int slotsIndex = 0;

			inventoryData["coins"] = myInventory["coins"];
			foreach (KeyValuePair<string, int> item in myInventory) {
				if (item.Key == "coins") continue;
				inventoryData[slots[slotsIndex] + "Name"] = item.Key;
				inventoryData[slots[slotsIndex] + "Amount"] = item.Value;
				Debug.Log(slots[slotsIndex] + "Name" +": " + item.Key + " - " + slots[slotsIndex] + "Amount" + ": " + item.Value);

			inventoryData.SaveAsync().ContinueWith(tt => {
			Debug.Log("Save Completed");


I had the same issue with my Application (on Android). To get it to work I used OnApplicationPause instead.

public void OnApplicationPause(bool pauseStatus)
    if (pauseStatus == true)

However, I could not use the normal SaveAsync() API for saving. Instead I did a synchronous save through the REST API (Parse Platform).

In the synchronous save you have to upload your data as JSON.

WebClient client = new WebClient();

client.Headers.Add("X-Parse-Application-Id", ApplicationId);
client.Headers.Add("X-Parse-REST-API-Key", RestApiKey);
client.Headers.Add("Content-Type", "application/json");

string json = yourParseObjAsJson;
byte[] data = Encoding.UTF8.GetBytes(json);

var uri = string.Format("https://api.parse.com/1/classes/{0}/{1}", obj.ClassName, obj.ObjectId);
client.UploadData(uri, "PUT", data);