How can I get a devices unique ID in Swift?
I need an ID to use in the database and as the API-key for my web service in my social app. Something to keep track of this devices daily use and limit its queries to the database.
Thanks!
How can I get a devices unique ID in Swift?
I need an ID to use in the database and as the API-key for my web service in my social app. Something to keep track of this devices daily use and limit its queries to the database.
Thanks!
Swift 2.2
For Swift 3.X Latest Working Code, Easily usage;
You can use devicecheck (in Swift 4) Apple documentation
Typical usage:
Server action needs:
See WWDC 2017 — Session 702
more from Santosh Botre article - Unique Identifier for the iOS Devices
You can use identifierForVendor public property present in UIDevice class
EDIT Swift 3:
END EDIT
You can use this (Swift 3):
For older versions:
or if you want a string:
There is no longer a way to uniquely identify a device after the user uninstalled the app(s). The documentation says:
You may also want to read this article by Mattt Thompson for more details:
http://nshipster.com/uuid-udid-unique-identifier/
Update for Swift 4.1, you will need to use:
I've tried with
instead
and it works.