How to get iOS device MAC address programmatically

后端 未结 5 1106
情歌与酒
情歌与酒 2020-11-28 12:53

How do I get an iOS device\'s MAC code programmatically in my app?

5条回答
  •  被撕碎了的回忆
    2020-11-28 13:12

    Now iOS 7 devices – are always returning a MAC address of 02:00:00:00:00:00.

    So better use [UIDevice identifierForVendor]

    so better to call this method to get app specific unique key

    Category will more suitable

    #import "UIDevice+Identifier.h"
    
    - (NSString *) identifierForVendor1
    {
        if ([[UIDevice currentDevice] respondsToSelector:@selector(identifierForVendor)]) {
            return [[[UIDevice currentDevice] identifierForVendor] UUIDString];
        }
        return @"";
    }
    

    Now call above method to get unique address

    NSString *like_UDID=[NSString stringWithFormat:@"%@",
                    [[UIDevice currentDevice] identifierForVendor1]];
    
    NSLog(@"%@",like_UDID);
    

提交回复
热议问题