Automatic Cloud Storage

One of the new features of the SandBoxd API is cloud storage. With cloud storage, games can store user data to SandBoxd servers for access across all devices that the user owns. Think of it as localStorage that is shared between all the user's devices.

Since localStorage is so similar, the SandBoxd JavaScript library offers a feature called automatic cloud storage which will automatically upgrade the localStorage object to a cloud storage object. Most games are already using localStorage for tracking game progress, so we figured this was an appropriate substitution.

Include the following lines before any other script to turn on automatic cloud storage:

<script src='//'></script>
sandboxd.init(GAMEID, "APIKEY");

GAMEID and APIKEY are provided to you in the Manage Game page.

That's it! All calls to localStorage will now be sent to the SandBoxd cloud instead.

localStorage.setItem("myKey", "This will be stored to cloud storage!");
console.log(localStorage.getItem("myKey"));		//Will print "This will be stored to cloud storage!"

//Equivalently we can get the value through the storage API"myKey", function (err, data) {
	console.log(data.value);		//Will print "This will be stored to cloud storage!"


sessionStorage remains unaffected. You can still use it normally.

Guest users will fall back to regular localStorage.

You must make sure to include the sandboxd.autoCloudStorage() line before any calls to localStorage are made to initialize things properly.

The localStorage array-like notation (IE localStorage["key"]) will not work. You should be using getItem and setItem anyways.

A local cache is maintained to prevent wait times on the synchronous localStorage calls. The cache is populated on application launch, so the application will never freeze after the initial load.