UIDevice uniqueIdentifier deprecated - What to do now?

后端 未结 30 2677
日久生厌
日久生厌 2020-11-21 06:07

It has just come to light that the UIDevice uniqueIdentifier property is deprecated in iOS 5 and unavailable in iOS 7 and above. No alternative method or pr

30条回答
  •  被撕碎了的回忆
    2020-11-21 06:39

    Based on the link proposed by @moonlight, i did several tests and it seems to be the best solution. As @DarkDust says the method goes to check en0 which is always available.
    There are 2 options:
    uniqueDeviceIdentifier (MD5 of MAC+CFBundleIdentifier)
    and uniqueGlobalDeviceIdentifier(MD5 of the MAC), these always returns the same values.
    Below the tests i've done (with the real device):

    #import "UIDevice+IdentifierAddition.h"
    
    NSLog(@"%@",[[UIDevice currentDevice] uniqueDeviceIdentifier]);
    NSLog(@"%@",[[UIDevice currentDevice] uniqueGlobalDeviceIdentifier]);
    

    XXXX21f1f19edff198e2a2356bf4XXXX - (WIFI)UDID
    XXXX7dc3c577446a2bcbd77935bdXXXX - (WIFI)GlobalAppUDID

    XXXX21f1f19edff198e2a2356bf4XXXX - (3G)UDID
    XXXX7dc3c577446a2bcbd77935bdXXXX - (3G)GlobalAppUDID

    XXXX21f1f19edff198e2a2356bf4XXXX - (GPRS)UDID
    XXXX7dc3c577446a2bcbd77935bdXXXX - (GPRS)GlobalAppUDID

    XXXX21f1f19edff198e2a2356bf4XXXX - (AirPlane mode)UDID
    XXXX7dc3c577446a2bcbd77935bdXXXX - (AirPlane mode)GlobalAppUDID

    XXXX21f1f19edff198e2a2356bf4XXXX - (Wi-Fi)after removing and reinstalling the app XXXX7dc3c577446a2bcbd77935bdXXXX (Wi-Fi) after removing and installing the app

    Hope it's useful.

    EDIT:
    As others pointed out, this solution in iOS 7 is no longer useful since uniqueIdentifier is no longer available and querying for MAC address now returns always 02:00:00:00:00:00

提交回复
热议问题