TVML persistant storage

Hello,


From a TVML app what are my options for persistant stogage of small bits of data?


Basically i want to save text data until the person has turned on the Apple TV again.


I have seen vague references, but was wondering is anyone had a bit of code they could point me to?


Thanks

Accepted Reply

Or https://developer.apple.com/documentation/tvmljs/storage

Replies

You can write your own system and bridge it to TVMLKit JS. Or use our UserDefaults storage: https://developer.apple.com/documentation/tvmljs/userdefaults

Or https://developer.apple.com/documentation/tvmljs/storage

This was a great answer, but i wanted something simpler that i could execute purely in JavaScript

Thank, i was over thinking. THis worked for me.


if (localStorage) {

// sessionStorage is only while the app is running

console.log("Supports localStorage");

localStorage.setItem("111111", "1/31/2018");


console.log("localStorage.length = " + localStorage.length);

console.log("localStorage.key(0) = " + localStorage.key(0));

console.log("localStorage.getItem(localStorage.key(0)) = " + localStorage.getItem(localStorage.key(0)));

} else

console.log("NO slocalStorage");