Jump to content
  • Advertisement

Recommended Posts

I am developing a cross platform game for which I needs to generate unique identifier (User ID) for each user. I known some platform (Android or iOS) specific approaches to get device related identifiers but I am looking for a solution independent of the device identifiers.

User ID Requirements:

 1. Independent of the device's platform
 2. Offline implementation (no communication with any servers)
 3. Without sign-up process

I have implemented one approach to create User IDs where I store the system time when the game was launched for the first time on the device.

I have following questions:

 1. Are there any other approaches to generate User IDs (which will meet the above requirements)?
 2. What are the common approaches to create unique identifiers with taking any information from the user?
 3. Are there any third party plug-ins to implement User IDs?

I would appreciate any suggestions and thoughts on this topic.

EDIT:

There are lot of responses to use UUID/GUID. Generally, this approach looks fine but I am looking for a solution which can generate same User ID even if the user reinstall the game.

Edited by Octane_Test
more information

Share this post


Link to post
Share on other sites
Advertisement

Guids are one thing you could look into.

So they have to be able to get an ID while they are offline and not signed up. If they are offline then it won't really matter what their ID is until they come online. Once they are online you can assign them a new ID that is unique throughout everyone else that is online.

I'd use an integer as their ID. when they sign up, give them the next available integer. that can be their user ID, so even when they are offline they will use that ID. If they need to get an ID without signing up, maybe do something like a session ID, so once someone connects online, they will get the next available session ID. again if they are offline the ID won't matter what it is, only when they come online.

One last thing you can do is get device specific information, like the hard drive serial number plus mac address plus some other hardware serial. This would of course go into your platform dependent section of code, since each platform is going to have different ways of getting this information. once you have that string of serials, just md5 hash it or something to get a normalized string so everyone uses the same string size for their ID.

I wouldn't use the time they started the app with, because it would be possible for multiple people to have started the app at the same time in their local machines time

Share this post


Link to post
Share on other sites

Generate a random 128-bit integer in some way. As iedoc said, you can do that by computing the md5sum of some machine-specific details, but you can also throw the timestamp of when the program was started in there, or some hardware-generated random numbers. You can also ask the user to take a picture (do you need a profile picture?) and take the md5sum of the image.

If you do a decent job of making the numbers random, 128 bits is enough to not expect any collisions ever. For instance, if you have 26 billion users, the probability of a collision is 10^-18. If for some reason you want to use 64 bits only, it might be OK, depending on how many users you expect: With 6 million users, the probability of a collision would be about 10^-6. I wouldn't go lower than 64 bits. See https://en.wikipedia.org/wiki/Birthday_problem

 

Share this post


Link to post
Share on other sites

UUID is what you are looking for. There are plenty open source implementations for all kinds of languages.

Share this post


Link to post
Share on other sites

Some things to also consider:

1) Will the game keep scores online for others to see?

2) Are there achievements?

3) Are there levels/progress points/character(s) stats?

If yes, you will have to support them using multiple devices with the same ID or to transfer their profiles to a new device without losing all their progress too.  So having them type 64-128 bit integer is likely not a great idea.  You might have to make a database that assigns IDs.

Share this post


Link to post
Share on other sites
15 hours ago, iedoc said:

Guids are one thing you could look into.

So they have to be able to get an ID while they are offline and not signed up. If they are offline then it won't really matter what their ID is until they come online. Once they are online you can assign them a new ID that is unique throughout everyone else that is online.

I'd use an integer as their ID. when they sign up, give them the next available integer. that can be their user ID, so even when they are offline they will use that ID. If they need to get an ID without signing up, maybe do something like a session ID, so once someone connects online, they will get the next available session ID. again if they are offline the ID won't matter what it is, only when they come online.

One last thing you can do is get device specific information, like the hard drive serial number plus mac address plus some other hardware serial. This would of course go into your platform dependent section of code, since each platform is going to have different ways of getting this information. once you have that string of serials, just md5 hash it or something to get a normalized string so everyone uses the same string size for their ID.

I wouldn't use the time they started the app with, because it would be possible for multiple people to have started the app at the same time in their local machines time

Thank you for the reply. I agree with your suggestion of using GUID (UUID) as User ID. I don't want to generate any identifier based device's hardware so that I don't violate Apple's or Google's guidelines.

Given I am fetching local machine's time in milliseconds, what are the chances of collision?

8 hours ago, Mike2343 said:

Some things to also consider:

1) Will the game keep scores online for others to see?

2) Are there achievements?

3) Are there levels/progress points/character(s) stats?

If yes, you will have to support them using multiple devices with the same ID or to transfer their profiles to a new device without losing all their progress too.  So having them type 64-128 bit integer is likely not a great idea.  You might have to make a database that assigns IDs.

Answers matching your questions:

  1. No
  2. No
  3. No

I am fine with if a new User ID is generated when a  player play the game on other device.

Share this post


Link to post
Share on other sites
19 hours ago, Octane_Test said:

There are lot of responses to use UUID/GUID. Generally, this approach looks fine but I am looking for a solution which can generate same User ID even if the user reinstall the game

If you want some kind of staticness you should take a look at Bitcoin. Some wallets give the feature to ressemble an Id by getting some kind of personal information into the generator process, a password for example or PIN. So even if a user would loose his wallet for some reason, chances are there to restore it from those informations.

But you know when going for Android there is a little chance that those data will be keeped for you even if a user uninstalles your app. We have had (even on newer Android versions) the problem that old game data was still there when we did not hard uninstall the app from ADB, an uninstall on the device gave those zombie data

Share this post


Link to post
Share on other sites
On 2/1/2018 at 6:43 AM, Octane_Test said:

There are lot of responses to use UUID/GUID. Generally, this approach looks fine but I am looking for a solution which can generate same User ID even if the user reinstall the game.

You definitely don't want to use the time. I just reread your original post and you said you keep track of the first time the user opens the app. there's only around 80 million milliseconds in a day, so it's highly likely that you will eventually have multiple people with the same id, especially since apps are open most often during certain times of day. I suppose you could use the datetime or epoch, that would be better, but still could result in duplicate id's if you were to say promote your game, and a bunch of people started playing your game that day. Also, where would you store that id? when they reinstall the app, or clear the app data, you'll probably lose that id unless you save it somewhere else on the phone

Could you clarify what you plan to do with the ID? Does the ID have to be the same every time the user comes online? or do you expect the ID to change every time they open the app? You don't want the user to get a new ID when they reinstall the app, but what if they change phones? can they get a new ID then?

Maybe a simple login system with username and password when they come online would do the trick, that way they will have the same ID no matter what, and you won't have to get information about their device or anything like that.

Share this post


Link to post
Share on other sites

For a mobile game i have been involved in, we used a server generated UUID and the mobiles unique device id to identify a user, then if they put in their email, later on which was optional, we could restore their account in case they reinstalled the app or changed their phone. 

Edited by flodihn

Share this post


Link to post
Share on other sites

Use the device's mac address?  If the user changes hardware, yeah, it'll change, but that's not super often.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!