#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
网友评论