导入 SAMKeychain 库
配置到 路径
封装DeviceId的类
//
// MYIDeviceld.h
// EPStore
//
// Created by ArrQ on 2017/2/21.
// Copyright © 2017年 zhifenx. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface MYIDeviceld : NSObject
/**
获取设备的 UUID
@return UUID 字符串
*/
+ (NSString *)getDeviceId;
@end
//
// MYIDeviceld.m
// EPStore
//
// Created by ArrQ on 2017/2/21.
// Copyright © 2017年 zhifenx. All rights reserved.
//
#import "MYIDeviceld.h"
#import "SAMKeychain.h"
@implementation MYIDeviceld
+ (NSString *)getDeviceId{
NSString *currentDeviceUUIDString = [SAMKeychain passwordForService:@"www.youshengedu.net" account:@"uuid"];
if (!currentDeviceUUIDString) {
// NSUUID *currentDeviceUUID = [UIDevice currentDevice].identifierForVendor;
// currentDeviceUUIDString = currentDeviceUUID.UUIDString;
// [SAMKeychain setPassword:currentDeviceUUIDString forService:@"www.youshengedu.net"account:@"uuid"];
}
return currentDeviceUUIDString;
}
@end