Personal License $24.99

1 application Binary restricted distribution Commercial use allowed Can modify source Read full license

Company License $189.99

Unlimited projects Source and binary distribution Commercial use allowed Distribute modifications 6 months support Read full license

You need to log-in or create an account
  • Create an account
  • Log-in
  • Please use your real name.
  • Account activation link will be sent to this address.
  • Minimum 8 characters

Clicking this button confirms you read and agreed to the terms of use and privacy policy.

Starting from $ 24.99

View Pricing 14 days money-back guarantee

iOS 5 Device Identifier

Global Unique Device Identifier replacement for Apple's deprecated UIDevice API in iOS 5.

Description

This component is a lightweight yet powerful category on UIDevice which allows your application to access a globally unique identifier for a device.

Since Apple has deprecated the hardware specific identifier in iOS 5, iOS 5 Device Identifier aims to replace it with a collaborative solution. It utilizes UIPasteboard to create a unique ID which any application can access. Plus, the UIPasteboard is encrypted so as to deter any tampering.

Back to top

Security

The obvious problem one encounters when storing the ID on the pasteboard is security. A "man-in-the-middle" attack is the first problem which comes to mind. Conceivably, some nasty iOS developer could simply overwrite or change the ID stored in the pasteboard causing havoc for all the apps on the device. iOS 5 Device Identifier solves this problem via a few methods:

  1. Believe in the goodness of iOS developers. Seriously, there isn't anything completely "secure" iOS 5 Device Identifier can do. Since you have the source, you can do whatever the code does. If there are more evil iOS devs than I originally thought (which I doubt), I will change the encryption algorithms and distribute iOS 5 Device Identifier as a static library which will make it more difficult to view my encryption methods. Obviously, like DRM, no solution is perfect, it all depends on the evil inside of our hearts. Of course, if any developer manages to figure out the encryption method even in the static library, they're probably a bad-ass coder and not motivated to be a complete jerk.

  2. Security by obscurity. OK, not the best technique in the book (does it even count as a technique?), but is one of our best options in this situation. Basically, iOS 5 Device Identifier uses a special method for naming custom pasteboards so that you'd have to read the source code to know how it generates the names. iOS 5 Device Identifier also keeps around 5 clipboards which it uses in case one of the clipboards is invalid or tampered with. Since you can't explicitly list all the pasteboards via the UIPasteboard class, this method adds a decent layer of protection. Mainly it just stops another developer from accidentally overwritten the unique ID.

  3. Full AES encryption of unique identifier. In other words, the attacker would have to know how we generate our key to properly change the ID. If we don't have the ID cached and must look to the pasteboard, we will always verify that the decrypted ID has the correct form, etc. Again, if the attacker is determined enough he can easily figure out how iOS 5 Device Identifier generates the encryption key. If this becomes an issue, I'll simply release a new algorithm but as a static library which should reduce the problem.

  4. Per-app caching. Seems obvious but once we find the existing ID from the global pasteboard or generate one ourselves, we cache it in NSUserDefaults. Since NSUserDefaults are sandboxed, this "ID caching" ensures the ID is now un-changeable.

Security Conclusion

Unless there is some really evil iOS developer out there, iOS 5 Device Identifier is about as secure as is reasonably possible. There is also really only one attack point which is the pasteboard. However, since the app grabs the ID from the pasteboard only once then caches it, the probability of shenanigans is fairly low.

Back to top

vs MAC Address ID

You may have seen many other open-source solutions around the web which use the MAC address as the new unique ID. Unfortunately, this technique has a few downsides; the most prominent being the fact that the MAC address can actually change and thus render different IDs for different apps.

Unlike this solution, iOS 5 Device Identifier creates a unique ID using CFUUID which is identical in form to the device identifier. It then saves it to UIPasteboard and NSUserDefaults to ensure the single device ID is immutable.

Back to top

Usage (hint, it's simple)

Did I mention iOS 5 Device Identifier is simple?

[[UIDevice currentDevice] uniqueIdentifier]

and you're done. iOS 5 Device Identifier is a complete drop-in replacement for the current UIDevice method.

Back to top

Features

  • Globally unique ID per device (not app specific)
  • Drop-in replacement for existing API
  • IDs are exactly the same form, length, etc., as current device IDs
  • Secure by obfuscating pasteboards, encrypting, and verifying when decrypting
  • Efficient; after initial fetch from pasteboard the library caches in NSUserDefaults
  • Lightweight: one file, one category
  • Network effect is cool. The more apps that use this the more identified devices we'll have.
Read all 13 comments »

Questions & Comments

  • pseudon said:

    2 months ago
    How does a user Opt Out of being globally tracked across apps, without having to wipe their device all the time?
    • Sam Stewart Author said:

      2 months ago
      That is correct, the only way to opt out is to erase all data as the UUID is stored in a shared pasteboard.
    • pseudon said:

      2 months ago
      How can a user find out if any of their apps are using "iOS 5 Device Identifier"?
    • Sam Stewart Author said:

      2 months ago
      The app would need to report that itself. This is a library and not a user interface component and hence cannot influence the display of the app.
    • pseudon said:

      2 months ago
      Would you consider adding a function that would allow a developer to create an app that would detect and delete any and all pasteboard instances of the "iOS 5 Device Identifier" (i.e., bypass the security through obscurity)? I assume that a subsequently-generated "iOS 5 Device Identifier" would be different from all prioir instances just as in the case of wiping a device back to defaults.
    • Sam Stewart Author said:

      2 months ago
      @pseudon the app would defeat the purpose of this library which is to uniquely identify each iOS device.
    • pseudon said:

      2 months ago
      It wouldn't defeat the purpose, it would only facilitate users' rights to not be tracked for those who choose that path. To leave it up to hundreds or thousands of apps to correctly implement an opt-out, and expect consumers to have to opt out of tracking in every app separately, would be folly.
  • Lee Armstrong said:

    7 months ago
    Yes but the point of the UDID is that it is the same surely?
    • Sam Stewart Author said:

      7 months ago
      Certainly; and it is the same, unless the user completely wipes the device. In that case, the device will appear as "new" which is exactly what the user wanted.

      Unless you use a hardware ID (like the MAC address), which is exactly what Apple is trying to deprecate, then you can't guarantee the ID won't reset if the user wipes the device.

      Perhaps adding an option to force the component to use the MAC address would be useful?
  • Eimantas said:

    7 months ago
    What happens if user decides to wipe out all the data and reset device's settings (Settings -> General -> Reset -> Erase All Content and Settings)?
    • Sam Stewart Author said:

      7 months ago
      Hi Eimantas,
      Excellent question, and definitely something to consider. If the user chooses to "wipe" the device, then "iOS 5 Device Identifier" would simply create a new unique id and treat the device as "factory restored" when the app is next started. In other words, it would appear as a new device.

      Since this is probably what the user wanted, it works out nicely.
    • Lee Armstrong said:

      7 months ago
      But the mac address wouldn't change, I don't get this!
    • Sam Stewart Author said:

      7 months ago
      You are correct Lee. However, "iOS 5 Device Identifier" doesn't actually use the mac address as the unique identifier since Apple may deprecate that in the future. Instead, it uses a shared UIPasteboard system to guarantee reliability without fear of deprecation. Since a device reset wipes all UIPasteboards and NSUserDefaults, the saved ID will be reset.

      Hopefully this clarifies.

Leave a comment

You must be logged-in to leave a comment.
Log-in now or register for a free account.
You must be logged-in to vote. Log-in to your account or register now.

User Reviews

No reviews have been submitted yet.

Starting from $ 24.99

View Pricing 14 days money-back guarantee