Click here to Skip to main content
Click here to Skip to main content

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

By , 19 May 2010
 

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

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.

Get A Reference To The Current Device

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 *device = [UIDevice currentDevice];

Here Is What UIDevice Will Tell You

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

    uniqueIdentifier Can Be Pretty Useful

    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:

    NSString *deviceID = device.uniqueIdentifier;
    

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

    NSLog(@"%@", deviceID);
    

    You will get something that looks a bit like this:

    XXX70A50-ER31-X3X3-BDB2-3ED40EKIUN4D

    Why Do It?

    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?

  • License

    This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    About the Author

    MobileAppMastery
    United States United States
    Member
    No Biography provided

    Sign Up to vote   Poor Excellent
    Add a reason or comment to your vote: x
    Votes of 3 or less require a comment

    Comments and Discussions

     
    Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
    You must Sign In to use this message board.
    Search this forum  
        Spacing  Noise  Layout  Per page   
    -- There are no messages in this forum --
    Permalink | Advertise | Privacy | Mobile
    Web03 | 2.6.130516.1 | Last Updated 19 May 2010
    Article Copyright 2010 by MobileAppMastery
    Everything else Copyright © CodeProject, 1999-2013
    Terms of Use
    Layout: fixed | fluid