Authored by 周蓉君

优化新旧设备判断逻辑。Review by 硬币。

... ... @@ -69,6 +69,7 @@ static int const kOpenUDIDRedundancySlots = 100;
static NSString * const kYohoSecretInfo = @"com.yoho.buy.secretinfo";
static NSString * const kYohoBuyUdid = @"com.yoho.buy.udid";
static BOOL isNew = YES;
static NSString * const kYohoDeviceInfo = @"com.yoho.buy.deviceinfo";
static NSString * const kYohoBuyUsedDevice = @"com.yoho.buy.useddevice";
... ... @@ -397,12 +398,9 @@ static NSString * const kYohoBuyUsedDevice = @"com.yoho.buy.useddevice";
+ (void) setUsedDevice
{
NSMutableDictionary *yohoinfoKVPairs = (NSMutableDictionary *)[YH_KeychainStore load:kYohoDeviceInfo];
if (yohoinfoKVPairs == nil) {
yohoinfoKVPairs = [NSMutableDictionary dictionary];
}
if (![yohoinfoKVPairs[kYohoBuyUsedDevice] isEqualToString:@"Y"]) {
if ([self isNewDevice]) {
isNew = NO;
NSMutableDictionary *yohoinfoKVPairs = [NSMutableDictionary dictionary];
[yohoinfoKVPairs setObject:@"Y" forKey:kYohoBuyUsedDevice];
[YH_KeychainStore save:kYohoDeviceInfo data:yohoinfoKVPairs];
}
... ... @@ -410,18 +408,15 @@ static NSString * const kYohoBuyUsedDevice = @"com.yoho.buy.useddevice";
+ (BOOL) isNewDevice
{
static BOOL isNew = YES;
if (isNew == NO) {
return NO;
}
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
NSMutableDictionary *yohoinfoKVPairs = (NSMutableDictionary *)[YH_KeychainStore load:kYohoDeviceInfo];
if (yohoinfoKVPairs && yohoinfoKVPairs[kYohoBuyUsedDevice]) {
isNew = NO;
}
});
NSMutableDictionary *yohoinfoKVPairs = (NSMutableDictionary *)[YH_KeychainStore load:kYohoDeviceInfo];
if (yohoinfoKVPairs == nil || yohoinfoKVPairs[kYohoBuyUsedDevice] == nil) {
return YES;
} else {
isNew = NO;
return NO;
}
return isNew;
}
@end
... ...