iOS Development
UIDevice
uniqueIdentifier
API Deprecation
Mobile Security

UIDevice uniqueIdentifier deprecated - What to do now?

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

In recent years, privacy and data security have become paramount within the tech industry, leading to significant changes in how devices and apps handle user data. A notable evolution in Apple's iOS platform is the deprecation of UIDevice uniqueIdentifier. This article explores the implications of this deprecation, alternatives you can use, and guidelines for handling user identification more securely and responsibly.

Understanding UIDevice uniqueIdentifier

UIDevice uniqueIdentifier was an API used in iOS to obtain a unique identifier for an iOS device. Until its deprecation, it was commonly used by developers to track devices for analytics, personalization, and user-related activities. The identifier provided by this API was unique to each device and remained constant across app installs and system reboots, making it a reliable means of identifying a specific device.

Deprecation Reasons

The primary reason for deprecating UIDevice uniqueIdentifier relates to privacy concerns. A constant device identifier could lead to persistent tracking of users without their explicit consent, violating user privacy. Apple recognized these risks and decided that the drawbacks outweighed the benefits, particularly as GDPR and similar legislations require more stringent data privacy practices.

What to Do Now?

With the deprecation of UIDevice uniqueIdentifier, developers need to adapt their apps to use alternatives that align with privacy standards. Several options are available, each with its own use cases, benefits, and limitations.

1. Use identifierForVendor

identifierForVendor is provided by the UIDevice class and returns a unique UUID that identifies a device to the app's vendor. Here's how you can use it:

objective-c
NSUUID *vendorID = [[UIDevice currentDevice] identifierForVendor];
NSString *vendorIDString = [vendorID UUIDString];
  • Pros: It changes if the user deletes all apps from the same vendor and reinstalls them, aligning with user expectations of privacy.
  • Cons: Not suitable for identifying the same device across apps from different vendors.

2. App-Specific UUIDs

Developers can generate and store their own UUIDs within the app's sandbox. This identifier will remain unique to the app unless the user deletes and reinstalls the app.

objective-c
NSString *uuid = [[NSUUID UUID] UUIDString];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:uuid forKey:@"myAppSpecificUUID"];
  • Pros: Fully under developer control and app-specific, preventing cross-app tracking.
  • Cons: The identifier is lost if the user deletes the app.

3. Advertising Identifier (IDFA)

For apps that specifically need to track users for advertising, the Advertising Identifier (IDFA) can be used. However, users have the ability to limit ad tracking, and IDFA access is stricter.

objective-c
1#import <AdSupport/AdSupport.h>
2
3NSUUID *adID = [[ASIdentifierManager sharedManager] advertisingIdentifier];
4NSString *adIDString = [adID UUIDString];
  • Pros: Designed for advertising and allows tracking with user consent.
  • Cons: Subject to user opt-out, making it unreliable as a sole identifier.

Key Considerations

IdentifierUse CasesProsCons
identifierForVendorIntra-vendor app trackingChanges if all apps are deleted/reinstalled.Cannot track across different vendors.
App-Specific UUIDUnique per-app identificationDeveloper controlled, ensures privacy.Deletes with the app.
IDFAAdvertising and trackingTracks users across apps, conforms to ad industry standards.Subject to user opt-out, privacy concerns.

Additional Considerations

  1. User Consent: It is crucial to obtain explicit user consent before tracking or storing any form of device or user identifier. This aligns with legal standards and reinforces trust.
  2. Transparency: Inform users why their data is being collected and how it will be used. Transparency should be part of an app’s core design philosophy.
  3. Data Security: Implement robust security measures to protect the identifiers and any associated data stored within your app.
  4. Regular Updates: Stay informed about platform changes and be ready to update your app as new privacy guidelines are established or old methods become obsolete.

Conclusion

The deprecation of UIDevice uniqueIdentifier reflects Apple's commitment to enhancing user privacy by limiting device tracking capabilities. While this creates challenges for developers, several viable alternatives facilitate user identification compliant with new privacy norms. Adjusting to these changes is not only necessary for compliance but also beneficial for cultivating a positive user relationship based on respect and transparency.


Related reading
Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

All Rights Reserved.