Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

File storage
Started by thassman Nov 13 2015 07:43 AM

29 replies to this topic
[TOPIC CONTROLS]
Page 1 of 2 1 2
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

thassman

[GLOBAL: userInfoPane.html]
thassman
  • Enthusiast

  • 63 posts
  • Corona SDK

Have had great success porting my upcoming platformer to the tvOS.

But one issue i cannot workaround, there is no persistent storage on tvOS, so all the io* calls do not work.

As far as i have been able to understand, only option is to use NSUserDefaults then you have 500kb of storage

 

I know this is early grounds, but just wanted you to have this on the radar, as saving a games state is pretty important i think

 

Keep up the good work :)

 



[TOPIC: post.html]
#2

blakeleftwich

[GLOBAL: userInfoPane.html]
blakeleftwich
  • Enthusiast

  • 59 posts
  • Corona SDK

Yes, this is my number one concern. All our apps are well under the 200MB limit but we need a solution for local storage for saving preferences. If there's no solution for this, we won't have the option to use IAPs.



[TOPIC: post.html]
#3

avlepel

[GLOBAL: userInfoPane.html]
avlepel
  • Contributor

  • 132 posts
  • Corona SDK

I got a first version of "Freeze! 2 - Brothers" working on the Apple TV, but I have the same problems saving my settings and values. 

 

Xcode gives me this error:

 

Nov 13 21:15:30 Apple-TV kernel[0] <Notice>: Sandbox: Freeze 2-ZIP tvO(178) deny(1) file-write-create /private/var/mobile/Containers/Data/Application/13B65E7C-4BC7-4513-8D84-3C8D55DBC506/Documents/settings.json 

 

I simply need this to store the progress of the user, that e.g. he is in World 03 in Level 17 and I need to store all the level times.

So I don't even need 500KB, 5KB would be enough.

 

But without the chance to save stats no games are possible.

 

Maybe that's the reason why the cool Coronalabs team started work on iCloud saves today.  :-)

 

But if we can get 500KB with NSUserDefaults like thassman wrote it would be perfect, too, and maybe faster to implement.

 

Thanks & best

Andreas



[TOPIC: post.html]
#4

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,197 posts
  • Enterprise

I'm going to throw out an option here. Regardless of what ever we do with iCloud, your Apple TV pretty much has to be network connected. Parse.com or setting up your own Coronium.io server and store whatever you want.  NSUserDefaults should not be hard to implement in Enterprise.

 

NSUserDefaults will have a 0.5mb limit

CloudKit's Key-Value pairs will have a 1mb limit

 

Finally, while there seems to be no local data store, Apple does talk about the caches directory.  Have you tried to open/close files in system.CachesDirectory?

 

Rob



[TOPIC: post.html]
#5

thassman

[GLOBAL: userInfoPane.html]
thassman
  • Enthusiast

  • 63 posts
  • Corona SDK

I do have a backend where i can store the games state.

But how do i get a unique id for the device, it has to be something that is returned by the OS, cause i cannot create it myself and save it locally as i normally would do.

 

Cheers,

Tommy



[TOPIC: post.html]
#6

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,197 posts
  • Enterprise

There is the OpenUDID plugin (iOS only) that will work. system.getInfo() has a "deviceID" option which should return an allowed unique ID that can be used. Of how about a novel idea, don't tie it to the device at all, but to a user ID. That way people on Android devices that support multiple users won't interfere with other user's saved data. If someone gets a new device, since it's tied to the user, not the device, they can pick up where they left off.

 

Rob



[TOPIC: post.html]
#7

avlepel

[GLOBAL: userInfoPane.html]
avlepel
  • Contributor

  • 132 posts
  • Corona SDK

Hi,

 

thanks for implementing iCloud-Key-Value-Storage, this really is great, I now will use this for "Freeze!" and "Freeze! 2 - Brothers" so the game progress is synced across all devices, even between the phone/tablet and upcoming tvOS versions.

 

But we still need access to NSUserDefaults:

 

https://developer.apple.com/library/tvos/documentation/Cocoa/Conceptual/UserDefaults/AccessingPreferenceValues/AccessingPreferenceValues.html

 

This is important according to Apple if the Apple TV is offline - the game still needs to know about the selected language, the current level of the game etc.

 

So the correct way to set this up is:

 

1.) save all the info (level progress etc.) you need for the player to continue his game locally using NSUserDefaults

2.) additionally save all this stuff using iCloud KVS to sync with the same game on phone/tablet

 

If Apple tv is online use the iCloud KVS values, if offline use the local backup from NSUserDefaults.

 

To set this up should be much less effort than implementing iCloud KVS - and again, thanks for that, will start to work with this now. :-)

 

Best

Andreas



[TOPIC: post.html]
#8

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,197 posts
  • Enterprise

We have a feature request for this at:   http://feedback.coronalabs.com/forums/188732-corona-sdk-feature-requests-feedback/suggestions/10744452-ability-to-read-nsuserdefaults-on-ios

 

But it doesn't have a lot of votes. Engineering said this should be easy to implement, but we just have to get it in the work queue.

 

Rob



[TOPIC: post.html]
#9

avlepel

[GLOBAL: userInfoPane.html]
avlepel
  • Contributor

  • 132 posts
  • Corona SDK

Hi Rob,

 

thanks for the tip, I just voted.

 

I guess when more dev will target tvOS this will get more important.

 

Best

Andreas



[TOPIC: post.html]
#10

JonPM

[GLOBAL: userInfoPane.html]
JonPM
  • Corona Geek

  • 1,077 posts
  • Corona SDK

I just voted as well.  This really is something that should be standard.  Other items, IMHO, like Game Center should require popular vote...



[TOPIC: post.html]
#11

avlepel

[GLOBAL: userInfoPane.html]
avlepel
  • Contributor

  • 132 posts
  • Corona SDK

I just voted as well.  This really is something that should be standard.  Other items, IMHO, like Game Center should require popular vote...


Hi Jon,

thanks for upvoting NSUserDefaults!

But on Game Cente support I strongly disagree, every game that needs to be taken seriously has to have at least Leaderboards and Achievements. It's not so much about the players (don't get me wrong, many love & demand this), it's more about Apple:

It's even harder to get picked by the Apple Editorial Team for a feature if you don't support basics like Game Center. They need stories, like "Freeze! 2 now is available for iOS and tvOS, and game progress, Achievements & Leaderboards are shared across all devices!".

With stories like this they will promote their Apple TV, and if you cannot deliver this promise they just will pick another game for a promotion. I will only publish the tvOS version of the game when I can support Game Center, otherwise my chance to be featured might be gone.


[TOPIC: post.html]
#12

Tobias Mueller

[GLOBAL: userInfoPane.html]
Tobias Mueller
  • Enthusiast

  • 66 posts
  • Corona SDK

Hi! I voted for NSUserDefaults, too. Support für Game Center on tvOS is also important for us. :)



[TOPIC: post.html]
#13

JonPM

[GLOBAL: userInfoPane.html]
JonPM
  • Corona Geek

  • 1,077 posts
  • Corona SDK

Hi Jon, thanks for upvoting NSUserDefaults! But on Game Cente support I strongly disagree, every game that needs to be taken seriously has to have at least Leaderboards and Achievements. It's not so much about the players (don't get me wrong, many love & demand this), it's more about Apple: It's even harder to get picked by the Apple Editorial Team for a feature if you don't support basics like Game Center. They need stories, like "Freeze! 2 now is available for iOS and tvOS, and game progress, Achievements & Leaderboards are shared across all devices!". With stories like this they will promote their Apple TV, and if you cannot deliver this promise they just will pick another game for a promotion. I will only publish the tvOS version of the game when I can support Game Center, otherwise my chance to be featured might be gone.

 

I am not saying Game Center is not important, because it is.  I'm merely saying the need to save data locally is a very basic necessity in comparison.  As you said, every game that needs to be taken seriously needs GC, but in contrast, every game needs local file storage.  If the Apple tvOS reviewers review apps in the same manner as they do iOS (i.e. in airplane mode), then lacking local persistent data storage could be grounds for rejection.  



[TOPIC: post.html]
#14

avlepel

[GLOBAL: userInfoPane.html]
avlepel
  • Contributor

  • 132 posts
  • Corona SDK

Hi Jon, of course, that's what I'm saying, read my earlier post about Apple expecting the apps to work offline. Because of this NSUserDefaults should have a high priority. I just objected to your suggestion to throw Game Center at the mercy of votes. And this in a threat about NSUserDefaults. ;-) Best Andreas

[TOPIC: post.html]
#15

Mike Hempfling

[GLOBAL: userInfoPane.html]
Mike Hempfling
  • Contributor

  • 253 posts
  • Corona SDK

What is the status for io.* capabilities for tvOS?



[TOPIC: post.html]
#16

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,197 posts
  • Enterprise

io* should work with system.CachesDirectory, system.TemporaryDirectory and system.ResourceDirectory. Anything else needs to go to iCloud.

 

Rob



[TOPIC: post.html]
#17

Mike Hempfling

[GLOBAL: userInfoPane.html]
Mike Hempfling
  • Contributor

  • 253 posts
  • Corona SDK

So there is no system.DocumentsDirectory for tvOS? What takes it place?



[TOPIC: post.html]
#18

Alex@Panc

[GLOBAL: userInfoPane.html]
Alex@Panc
  • Corona Geek

  • 1,733 posts
  • Corona SDK

The bulk of this thread deals with the fact that there is a very small amount of local storage available to tvOS apps. See below thread for details:

 

https://forums.developer.apple.com/thread/16967



[TOPIC: post.html]
#19

Mike Hempfling

[GLOBAL: userInfoPane.html]
Mike Hempfling
  • Contributor

  • 253 posts
  • Corona SDK

I only need a small amount to store a high score. I looked through the thread you provided but I did not see a solution for local persistent data.



[TOPIC: post.html]
#20

Alex@Panc

[GLOBAL: userInfoPane.html]
Alex@Panc
  • Corona Geek

  • 1,733 posts
  • Corona SDK

This is the thread that is discussing possible solutions/workarounds regarding local file storage for tvOS. You can read through this thread to get a feel for how tvOS development has been progressing, including resources about tvOS and it's various challenges. Rob Miracle created a tutorial here that talks about how to use the iCloud plugin so that Corona developers can target tvOS distribution.



[TOPIC: post.html]
#21

Mike Hempfling

[GLOBAL: userInfoPane.html]
Mike Hempfling
  • Contributor

  • 253 posts
  • Corona SDK

@Rob Miracle

 
When do you think there will be a solution for saving local files?


[TOPIC: post.html]
#22

Mike Hempfling

[GLOBAL: userInfoPane.html]
Mike Hempfling
  • Contributor

  • 253 posts
  • Corona SDK

Does the user have to be using iCloud for the iCloud plugin to work?



[TOPIC: post.html]
#23

JonPM

[GLOBAL: userInfoPane.html]
JonPM
  • Corona Geek

  • 1,077 posts
  • Corona SDK

I would imagine so.  It stores the data to that specific users "cloud".  



[TOPIC: post.html]
#24

Mike Hempfling

[GLOBAL: userInfoPane.html]
Mike Hempfling
  • Contributor

  • 253 posts
  • Corona SDK

Then I am sure this makes sense as a solution for storing game data (like high score, etc).



[TOPIC: post.html]
#25

JonPM

[GLOBAL: userInfoPane.html]
JonPM
  • Corona Geek

  • 1,077 posts
  • Corona SDK

The problem is your app also needs to work while the device is offline.




[topic_controls]
Page 1 of 2 1 2
 
[/topic_controls]