Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mlts22

macrumors 6502a
Original poster
Oct 28, 2008
540
35
Where would be a good place to start looking to give an app the ability to back up user information (saved games), so if they do a restore as new, they still can get their game saves and configuration back. Here are the ideas I've seen:

1: http server on the device. The user would have the username and password, and be able to fetch or upload their save games from a Web server. However, this means the user would have to have wi-fi access and know the iPhone's IP address.

2: Create/use a website where the game has a special website that it reads/writes data to and from. This takes some infrastructure, but it doesn't force a user to have wi-fi. Box.net comes to mind here, where the app would have a directory for saving game saves and such.

Are there any other ways to implement a way where a user can independently save/restore the game data? Thanks in advance.
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
If your saved games are in your sandboxed Documents folder then they are backed up by iTunes and restored when restored from Backup. Is there a particular reason you need more than this?
 

mlts22

macrumors 6502a
Original poster
Oct 28, 2008
540
35
If your saved games are in your sandboxed Documents folder then they are backed up by iTunes and restored when restored from Backup. Is there a particular reason you need more than this?

Yes, I would like to have the ability to save and restore save game blobs, so if someone restores their iPhone and sets the phone up as a new device, they can reload the saved games and pick up where they left off. Plus, this also gives the user the ability to remove the app, but perhaps later down the line, reinstall it and reload where they were.

The reason for this is that there are sometimes issues users have when upgrading phones where restoring from a backup gives issues. Having an alternate means of backup/restore would allow a user to still keep their saved game files even if they couldn't restore their old files.
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
The way I would do this is with iTunes file sharing. Have some kind of export feature in your app and write a file to your Documents folder. The user can then copy the file to their computer with iTunes.

Be aware of the possibilities this allows for cheating.
 

chown33

Moderator
Staff member
Aug 9, 2009
10,751
8,425
A sea of green
Where would be a good place to start looking to give an app the ability to back up user information (saved games), so if they do a restore as new, they still can get their game saves and configuration back. Here are the ideas I've seen:

1: http server on the device. The user would have the username and password, and be able to fetch or upload their save games from a Web server. However, this means the user would have to have wi-fi access and know the iPhone's IP address.
How could a server on the device ever store anything except on the device? At best, an on-device server is just an intermediary to an off-device storage service. Then your game might as well just go directly to the off-device storage service in the first place; a proxy doesn't gain you anything.


Are there any other ways to implement a way where a user can independently save/restore the game data? Thanks in advance.
Any off-device storage service would work. There are plenty of them: MobileMe/iDisk, Amazon S3, SkyDrive, etc. All you have to do use communicate with the service using the proper protocol and authenticators. A small matter of programming.

iDisk uses WebDAV, which is a standard well-documented protocol.

S3 uses HTTP REST requests with some service-specific HTTP headers that nonetheless fit within the well-defined HTTP 1.1 standard. It's also well-documented.

You should probably start by researching storage services and their protocols. Then look for existing libraries, such as ones that calculate the S3 authenticator, or do WebDAV. Then write modules that support each service, and let the user pick which one to use. You can then expand later by adding modules for new protocols and services.
 

mlts22

macrumors 6502a
Original poster
Oct 28, 2008
540
35
The way I would do this is with iTunes file sharing. Have some kind of export feature in your app and write a file to your Documents folder. The user can then copy the file to their computer with iTunes.

Be aware of the possibilities this allows for cheating.

By chance, do you have a link for where I can find information about that? I know some apps allow for uploading/downloading files, but not sure how to implement that functionality. What I would do is export an XML document with the stored save game items, add a hash system so if a changed game file is uploaded, the game won't accept it. Of course, this is easily hacked and the mechanism taken apart on a JB device, but it will do a decent job at keeping files secure.

How could a server on the device ever store anything except on the device? At best, an on-device server is just an intermediary to an off-device storage service. Then your game might as well just go directly to the off-device storage service in the first place; a proxy doesn't gain you anything.

The Web server would just be so the user could go fetch or upload the game saves, similar to how some apps like 1Password offer the ability to grab the database or upload one.


Any off-device storage service would work. There are plenty of them: MobileMe/iDisk, Amazon S3, SkyDrive, etc. All you have to do use communicate with the service using the proper protocol and authenticators. A small matter of programming.

iDisk uses WebDAV, which is a standard well-documented protocol.

S3 uses HTTP REST requests with some service-specific HTTP headers that nonetheless fit within the well-defined HTTP 1.1 standard. It's also well-documented.

You should probably start by researching storage services and their protocols. Then look for existing libraries, such as ones that calculate the S3 authenticator, or do WebDAV. Then write modules that support each service, and let the user pick which one to use. You can then expand later by adding modules for new protocols and services.

If I could implement functionality where a user can save/load files inside iTunes similar to how DocsToGo does it, that would be the best. However, if I can't, I'd probably go the multiple storage API route, offering Box.net, iDisk, S3, and maybe even a custom website to save files to.
 

chown33

Moderator
Staff member
Aug 9, 2009
10,751
8,425
A sea of green
The Web server would just be so the user could go fetch or upload the game saves, similar to how some apps like 1Password offer the ability to grab the database or upload one.

That sounds like a web client, not a web server. In particular, "fetch and upload" is what an HTTP client does, when it makes GET or PUT requests to a web server. The server fulfills the request, but it doesn't initiate it.
 

firewood

macrumors G3
Jul 29, 2003
8,108
1,345
Silicon Valley
That sounds like a web client, not a web server. In particular, "fetch and upload" is what an HTTP client does, when it makes GET or PUT requests to a web server. The server fulfills the request, but it doesn't initiate it.

Yes. But several iOS apps include web servers. You start up the app, there's a button in the app to start up a web server, and then you use the web browser on your Mac to do GET and PUT requests to upload and download file blobs from the server on the iPhone. That way you only need your iPhone, your Mac, and a wifi connection (access point, or served from your Mac); no web services in the sky needed.
 

chown33

Moderator
Staff member
Aug 9, 2009
10,751
8,425
A sea of green
Yes. But several iOS apps include web servers. You start up the app, there's a button in the app to start up a web server, and then you use the web browser on your Mac to do GET and PUT requests to upload and download file blobs from the server on the iPhone. That way you only need your iPhone, your Mac, and a wifi connection (access point, or served from your Mac); no web services in the sky needed.

Thanks for the summary. I wasn't aware of those.
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
Once you set up the ability for iTunes to access your Documents folder you still need a way to import/export files.

I would personally not do any other method (except maybe emailing the file as an attachment, which is easy to implement, although only works for exporting).

All of the web server methods were implemented before USB file sharing existed and are something of a pain to get working. I assume that this isn't a major feature of your app, just a convenience. Spend time on the implementation of the game, not this.
 

mlts22

macrumors 6502a
Original poster
Oct 28, 2008
540
35
Once you set up the ability for iTunes to access your Documents folder you still need a way to import/export files.

I would personally not do any other method (except maybe emailing the file as an attachment, which is easy to implement, although only works for exporting).

All of the web server methods were implemented before USB file sharing existed and are something of a pain to get working. I assume that this isn't a major feature of your app, just a convenience. Spend time on the implementation of the game, not this.

Very good advice. Ideally, I'd like a way for user game information to be backed up somewhere on the Net, but the expense of having a dedicated server that the app connects to for saves/restores would make it not worth it, unless I charged a premium for the app.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.