本文共 1044 字,大约阅读时间需要 3 分钟。
转载自:https://github.com/gekitz/UIDevice-with-UniqueIdentifier-for-iOS-5
a year ago | ||
2 years ago | ||
2 years ago | ||
9 months ago | ||
a year ago |
Apple stopped supporting a unique identifier for iOS. This source code solves the problem. It generates a unique identifier based on the mac address of the device in combination with the bundle identifier.
What you need to do:
copy NSString+MD5Addition
and UIDevice+IdentifierAddition
to your project.
if your are using ARC in your project, you have to add the -fno-objc-arc
flag to both files.
use [[UIDevice currentDevice] uniqueDeviceIdentifier]
to retrieve the unique identifier (it's a hash of your Bundle ID + MAC address)
use [[UIDevice currentDevice] uniqueGlobalDeviceIdentifier]
to retrieve a global unique identifier (it's a hash of the MAC address, used for tracking between different apps).
have fun and follow ;)
//Thanks to Erica Sadun for her UIDevice+Hardware Addition (used for the mac address retrieval).
see license file.