How can I retrieve the UDID on iOS?

前端 未结 10 1303
礼貌的吻别
礼貌的吻别 2020-12-14 06:05

I was wondering if it was possible to find out the UDID of the user\'s iPhone. Can someone shed some light?

10条回答
  •  爱一瞬间的悲伤
    2020-12-14 06:50

    I cannot comment, but I would like to warn others. In answer of DZenBot, all methods aren't giving the same results :


    Alternative 1 (NSUUID class):

    NSString *udid = [[NSUUID UUID] UUIDString];
    

    Alternative 2 (UIDevice class) (Available in iOS 6.0 and later):

    NSString *udid = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
    

    Alternative 1 generate a random UUID while Alternative 2 give a fixed UID which won't change.

提交回复
热议问题