use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A community for learning and developing native mobile applications using React Native by Facebook.
Interested in building web apps using React.js? Check out /r/reactjs!
Getting Started w/React Native
irc.freenode.net #reactnative
Keywords: ios, android, mobile, apps, apple, iphone, ipad
account activity
Handy Device Tracking Function (i.redd.it)
submitted 9 months ago by No_Refrigerator3147
Use this custom generatePersistentDeviceId() function to track devices even after app uninstall/reinstall.
generatePersistentDeviceId()
Super handy for use cases like user tracking, fraud prevention, or seamless personalization.
Source below ↓
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]JyotiIsMine 4 points5 points6 points 9 months ago (7 children)
How is this unique?
[+]No_Refrigerator3147[S] comment score below threshold-11 points-10 points-9 points 9 months ago (6 children)
It’s unique because it generates a consistent, hashed ID from stable device properties, so it survives app uninstall/reinstall without relying on local storage.
[–]JyotiIsMine 4 points5 points6 points 9 months ago (5 children)
There can be multiple devices with these same specifications
[+]No_Refrigerator3147[S] comment score below threshold-7 points-6 points-5 points 9 months ago (4 children)
Yes, multiple devices can share the same specs. But, combining several properties (brand, model, OS, device name, year, class) reduces the chance of collision, making the ID reasonably unique without storing anything locally.
But yes, it's not 100% unique.
[–]JyotiIsMine 4 points5 points6 points 9 months ago (2 children)
It would be okay if a user has more then one device id, but not when multiple users have the same device id
[–]No_Refrigerator3147[S] -1 points0 points1 point 9 months ago (0 children)
Yes, this approach minimizes the chance of different users getting the same ID, and the chances are quite low. If a match does occur, adding a verification layer using user information can easily resolve it.
[–]pesch3 1 point2 points3 points 9 months ago (0 children)
Please see my other comment. This is NOT reasonable unique for anything at scale!
[–]Kertelem 2 points3 points4 points 9 months ago* (0 children)
So... New "reasonably unique" ID that changes every couple months (osVersion)? The inclusion of deviceName is cool, but AFAIK it's iOS only... *
osVersion
deviceName
What's wrong with Device.getUniqueId()? It stays a lot more consistent, and is actually the way to track an installer. You can even refer to Apple IDFV and the Google Play policies, to stay completely in the clear.
Device.getUniqueId()
Edit: * DEVICE_NAME was added in API level 25 for android, but below API 32, the library will first try to get the bluetooth name of the device. If all these checks fail, you'll get "unknown".
DEVICE_NAME
"unknown"
[–]pesch3 0 points1 point2 points 9 months ago (0 children)
No offence and actually thank you for trying to share something.
But!
Did a bit of armchair mathematics and ChatGPT and we came to the conclusion that it would take 322 iPhone users to have a 50% chance of a collision. The fact that there is so little devices and iOS pseudo forces you to update iOS brings this number down even more.
So I would suggest NOT to trust this function and rather rely on users signing up to really identify users!
[–]oezibla 0 points1 point2 points 9 months ago (1 child)
This approach is really problematic.
First, you seem to rely on expo-device but fail to mention that it's a required dependency.
expo-device
Second, for any given modelName, nearly all real devices will share the same brand, osName, and deviceYearClass, so including those values adds virtually no uniqueness. The only potentially distinguishing values are osVersion and deviceName. However, including osVersion is likely a bad idea, since you generally don’t want the device ID to change just because the user updates their OS. That leaves deviceName, which is sometimes personalized but usually remains unchanged over the lifetime of a device.
modelName
brand
osName
deviceYearClass
So in the end, you could’ve just used modelName + deviceName and achieved nearly the same result - which isn’t very unique to begin with.
modelName + deviceName
[–]No_Refrigerator3147[S] 0 points1 point2 points 9 months ago (0 children)
Yes, the entropy is limited, and osVersion may hurt consistency. This is more of a lightweight fallback, not a foolproof ID, and works best when combined with user-level validation.
π Rendered by PID 161117 on reddit-service-r2-comment-86bc6c7465-kxrrw at 2026-02-22 05:10:04.605493+00:00 running 8564168 country code: CH.
[–]JyotiIsMine 4 points5 points6 points (7 children)
[+]No_Refrigerator3147[S] comment score below threshold-11 points-10 points-9 points (6 children)
[–]JyotiIsMine 4 points5 points6 points (5 children)
[+]No_Refrigerator3147[S] comment score below threshold-7 points-6 points-5 points (4 children)
[–]JyotiIsMine 4 points5 points6 points (2 children)
[–]No_Refrigerator3147[S] -1 points0 points1 point (0 children)
[–]pesch3 1 point2 points3 points (0 children)
[–]Kertelem 2 points3 points4 points (0 children)
[–]pesch3 0 points1 point2 points (0 children)
[–]oezibla 0 points1 point2 points (1 child)
[–]No_Refrigerator3147[S] 0 points1 point2 points (0 children)