How To Uniquely Identify Your User’s iPhone, iPad or iPod With UIDevice

Matthew Campbell, May 18th

Have you ever wanted a way to uniquely identify your user’s device? This is something that comes in handy when you are trying to implement a data syncing scheme or if you want to provide unique web based content to your user. If this sounds like something you want to do read on to find out how.

UIDevice is a class that stores information about the physical device that is running your app. You use UIDevice to get important information by using the currentDevice function. This is return a UIDevice object filled with information about the device that is running. Here is how to get this reference:

UIDevice objects will store more information that a simple unique identifier. You may use this object to get all kinds of information that will come in handy in this world of multiple devices. Here is what you get:

  • name – what the user named the device
  • model – iPhone, iPod or iPad
  • systemName – pretty much “iPhone OS”
  • systemVersion – tells you what iPhone OS version the system is running
  • orientation – what direction the device is currently facing
  • uniqueIdentifier – a string unique to each device based on information from the hardware itself
  • You retrieve all of this information in the same way by accessing the UIDevice object properties. Here is how to get the unique identifier from the device object we referenced above:

    And of course you may use this string in the normal ways:

    You will get something that looks a bit like this:


    Of course the why is up to you. Something that I have thought about is the situation where I want to be able to store user’s data for syncing purposes. You may also want to have your users share data or content with other apps, websites and so on. A simple way to start implementing this functionality could be to use this string to create a folder (or database primary key) to store your user’s data. Of course, you will need to do a bit more work on top of this as well.

    What do you think – useful trick?

    You must be logged in to post a comment.

  • Hours of videos, demos & screen casts
  • Detailed HANDS-ON Exercises
  • Much Much Much More
  • UIKit
  • Objective-C
  • Core Data
  • More!
  • Learn How To Make An iPhone App right now using my proven system.

    PS: Tons of us are having a blast living off our own code, join us now. Click here to get all the details.