codeTools

023-获取设备的UUID

2017-03-06  本文已影响8人  ArrQing
#import <Foundation/Foundation.h>

@interface EPDeviceld : NSObject
/**
 获取设备的UUID
 
 @return UUID字符串
 */
+ (NSString *)getDeviceId;
@end


#import "EPDeviceld.h"
#import "SAMKeychain.h"
@implementation EPDeviceld
/**
 通过key值“com.MaYi.youshengtec”获取设备的UUID,若有直接返回,没有创建UUID再返回。
 
 @return UUID string
 */


+ (NSString *)getDeviceId {
    NSString *currentDeviceUUIDString = [SAMKeychain passwordForService:@"com.yousheng.feng"account:@"uuid"];
    if (currentDeviceUUIDString == nil || [currentDeviceUUIDString isEqualToString:@""])
    {
        NSUUID *currentDeviceUUID  = [UIDevice currentDevice].identifierForVendor;
        currentDeviceUUIDString = currentDeviceUUID.UUIDString;
        [SAMKeychain setPassword:currentDeviceUUIDString forService:@"com.yousheng.feng"account:@"uuid"];
    }
    return currentDeviceUUIDString;
}

@end




上一篇 下一篇

猜你喜欢

热点阅读