2
\$\begingroup\$

I'm developing a game using Unity3D (for Android and iOS). I would like to save all user's virtual goods, so they are available even if the user remove and reinstall the app, or even if the user install it on a new device.

AFAIK an approach would be to authenticate the user, and save all the data on my backend server. But, to not reinvent the wheel, can you share your approach? i.e.: how do you authenticate users? are you using your own server, or any BaaS?

EDIT: After reading your answers, I think the best approach is to use "Google Play Game Services Saved Games" on Android, using the official plugin for Unity3D. For iOS, there is a similar feature for GameCenter, but I can't find any official plugin for Unity3D. But this plugin may work: https://www.assetstore.unity3d.com/en/#!/content/11626

Soomla plugin can be useful: https://www.assetstore.unity3d.com/en/#!/content/6103

Also, this plugin can be useful too: https://www.assetstore.unity3d.com/en/#!/content/20152

\$\endgroup\$
  • 1
    \$\begingroup\$ Can't you save on the client cloud? I know some games store my game data on my Google Drive account. It's protected as I can see the files, but I can't download them, and even less modify them. As a player the only thing I'm allowed to do is delete the file. Doesn't this fit your use case? One such a game that did so was Fallout Shelter. You can access this by going in Android's google Drive -> Parameters -> Automatic save of application data (or smth like that). URL for developers: developers.google.com/drive/v3/web/appdata \$\endgroup\$ – Olivier Grégoire Sep 1 '16 at 9:21
  • \$\begingroup\$ It may work. But I need a solution that works for iOS too. Not all iOS users have Google Drive account :( \$\endgroup\$ – Sergio Viudes Sep 1 '16 at 9:59
  • \$\begingroup\$ I don't know how it's done on iOS (never got any Apple product bar the iPod Classic), but it has similar capabilities as friends who play Fallout Shelter on iOS do have that feature as well. I guess this iCloud design guide might help you. If not, search for "ios app data cloud" (the link was the first with that query in my search). \$\endgroup\$ – Olivier Grégoire Sep 1 '16 at 10:14
2
\$\begingroup\$

You can save the data on the application user's cloud. This answer is basically my comments put in better form.

On Android, you can rely on Google Drive. Technically, you have access to a storage space in the user's Google Drive. The user can't interact with that storage space (read/write), but he can delete it (to be confirmed, I can't find that option anymore). Also, be careful with the total usage space because it's part of the quota of the user. Of course, the developer documentation is comprehensive. If you use such a data, your application will be listed in something like Google Drive > parameters > Automatic application save > Manage saves (sorry, I don't know the exact words, my phone is not in English).

On iOS, I don't really know because I never owned a cloud-connected Apple device. But from what I searched, I think you can follow the iCloud Design Guice.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Thanks for your detailed answer. I'll take a look at the documentation. \$\endgroup\$ – Sergio Viudes Sep 1 '16 at 11:27
  • \$\begingroup\$ For Android, with Google Play Game Services it seems to be easier, as there is a plugin for Unity, and I could use Cloud Saved Games I don't know if use GPGS for iOS too would be annoying for iOS users, as they may not have Google account \$\endgroup\$ – Sergio Viudes Sep 1 '16 at 13:34
2
\$\begingroup\$

My approach is to have my own server (a little one for now) with a REST API on it, and my game communicates with this API.

The authentication is another topic, I think you'll find a lot of things about that on StackExchange, I'm using a private/public key pair for that, creating a hash with private key and timestamp + other data to make sure the request is not a user-forged one and I ship the public key in the request headers to be able to find the user easily.

To implement authentication on client-side, you can simply make an endpoint called /user/auth, you request with GET, sending the user's credentials, if they are good, you send back the keypair, else you send a 400(Bad Request).

The goods are then stored in my database, with a POST method coming from client when it makes a valid purchase, sending me the google/iTunes purchase ID to make me able to ensure the purchase isn't a fake one.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Thanks for your answer. I need to take a look to client authentication. Instead of user/password registration, would be nice to offer authentication with Google account, or Apple account. I think it's more secure, and easy for the user. \$\endgroup\$ – Sergio Viudes Sep 1 '16 at 8:14
  • \$\begingroup\$ of course, but google auth token can be considered as an authentication data too, because if the user has his google auth token, it means that he provided the right username/password to google. Simply create a second auth endpoint that takes only the google auth token to authenticate the user. \$\endgroup\$ – Supamiu Sep 1 '16 at 8:25
  • \$\begingroup\$ This would require an SSO(oauth i think?) authentication layer for your REST-API, since this is a common problem that almost every REST-API has to solve I would assume there will likely be a number of out-of-the-box solutions available for whatever platform you build you REST-API on. There are also BaaS solutions available tailored to mobile gaming. I've looked into them but havent gotten around to using any of them, but they might offer what you need, at a cost. \$\endgroup\$ – Niels Sep 1 '16 at 9:07
  • \$\begingroup\$ I have a virtual server, and develop a REST-API is not a problem. So I prefer this option instead of pay for a BaaS. I'm now reading about how to use Google auth token, and some similar approach for iOS. \$\endgroup\$ – Sergio Viudes Sep 1 '16 at 9:18
1
\$\begingroup\$

Take a step back, don't treat it as an app or game or whatever. create a database, with fields that include the items *You know, give each user item an id, link that id to a user etc.

Then just have the application call the database when they log in, match the user id to the log on id, then get the item id's. This process will take milliseconds and is used by a wide range of applications, not just game related.

Just my two cents on trying to simplify it.

| improve this answer | |
\$\endgroup\$
  • 1
    \$\begingroup\$ Thanks for your answer. You are right, but instead of user/password registration, would be nice to offer authentication with Google account, or Apple account. I think it's more secure, and easy for the user. \$\endgroup\$ – Sergio Viudes Sep 1 '16 at 8:16
  • \$\begingroup\$ No worries, you could implement a system that checks google id aagainst your database id. Would be really niffty to set up too \$\endgroup\$ – Ryan white Sep 1 '16 at 12:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.