1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

A standard way to back up user information?

Discussion in 'iPhone/iPad Programming' started by mlts22, Aug 9, 2010.

  1. macrumors 6502

    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.
  2. Moderator


    Staff Member

    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?
  3. macrumors 6502

    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.
  4. macrumors 68030


    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.
  5. macrumors 603

    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.

    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.
  6. macrumors 6502

    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.

    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.

    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.
  7. macrumors 6502

  8. macrumors 603

    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.
  9. macrumors 603

    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.
  10. macrumors 603

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


    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.
  12. macrumors 6502

    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.
  13. macrumors newbie

    Mybe this will help you

    I just read about a new service that allows sharing data ability, this is the link: BackApps
    Good Luck!

Share This Page