Online saving allows a player to store their game data online, so they can start where they left off on different devices and websites. The APIs can save, retrieve, and delete small amounts of data like a game state. Data is limited to 50 Kb and API calls are blocked after 150 have been sent in 5 minutes.

Post API

  • Player data is referenced using a key. Player data saved using a key will be accessible using the same key.
  • Examples of data that can be stored by id.net
    • Number of levels cleared.
    • Total number of coins earned.
    • Unlocked shop items.
    • Unlocked characters.
  • It is possible to use different data types like String, Int, Vectors, Arrays, and a user defined Class. The Get API will return the same data type.

To minmize the amount of API calls being made, combine data in a single Class (see Post a Class below). This will prevent a game from making too many API calls and hitting the 150 calls per a 5 minute limit.

You may get an exception `not_saved` while posting data. This may occur only if you send the same key data repeatedly with delay less than 5 seconds, hence your data will be ignored by server.

Post a Class (Recommended)

Idnet.I.Post<UserProgressExampleData>("UserProgress", new UserProgressExampleData(5, 545, 3, 20.5f, "Big Character", true), (data, postDataException) =>
  if (postDataException == null)
  {
      Debug.Log("Data posted succesfully ");
  }
  else
  {
      Debug.LogError("Posting Data failed " + postDataException);
  }
});

Example of Creating a Class

internal class UserProgressExampleData
{
  public int NumOfLevelsUnlocked;
  public int TotalCoins;
  public int Lives;
  public float MaxDistanceTravelled;
  public string UnlockedCharacterName;
  public bool IsTutorialCompleted;
  
  public UserProgressExampleData(int numlevels, int totalcoins, int lives,float maxdistance,string charactername,bool istutorialcompleted)
  {
    NumOfLevelsUnlocked = numlevels;
    TotalCoins = totalcoins;
    Lives = lives;
    MaxDistanceTravelled=maxdistance;
    UnlockedCharacterName=charactername;
    IsTutorialCompleted=istutorialcompleted;
  }
}

Post a String

Idnet.I.Post<string>("MessageOfTheDay", "Hello World", (data, postDataException) => {
  if (postDataException == null)
  {
      Debug.Log("Data posted succesfully ");
  }
  else
  {
      Debug.LogError("Posting Data failed " + postDataException);
  }
});

Post an Array

Idnet.I.Post<string[]>("ExampleArray", new string[] {"Idnet", "Unity", "Games"});
  if (postDataException == null)
  {
      Debug.Log("Data posted succesfully ");
  }
  else
  {
      Debug.LogError("Posting Data failed " + postDataException);
  }
});

Post Data Without Using a Callback

// Posting a String.
Idnet.I.Post ("MessageOfTheDay", "Hello World");
	
//Posting Int[] Array
Idnet.I.Post ("ExampleIntArray", new int[] {1, 2, 3});
	
//Posting Custom class "UserProgressExampleData",Create your own class as per your usage.
Idnet.I.Post ("UserProgress", new UserProgressExampleData (5, 545, 3, 20.5f,"Big Character",true));
	

Delete Online Save

This API deletes all saved data of a player stored online. It’s usful for testing or in games that have a reset button.

  Idnet.I.DeleteKey ("KEY");