Authored by 周蓉君

device内新增afp字段,记录app安装指纹。Review by 硬币。

@@ -23,5 +23,6 @@ @@ -23,5 +23,6 @@
23 @property (copy, nonatomic, readonly) NSString *ifv; // ifv 23 @property (copy, nonatomic, readonly) NSString *ifv; // ifv
24 @property (copy, nonatomic, readonly) NSString *res; // 分辨率 24 @property (copy, nonatomic, readonly) NSString *res; // 分辨率
25 @property (copy, nonatomic, readonly) NSString *mac; // Mac地址 25 @property (copy, nonatomic, readonly) NSString *mac; // Mac地址
  26 +@property (copy, nonatomic, readonly) NSString *afp; // app安装指纹(40位随机数)
26 27
27 @end 28 @end
@@ -18,6 +18,8 @@ @@ -18,6 +18,8 @@
18 18
19 #import "YHDevice.h" 19 #import "YHDevice.h"
20 20
  21 +static NSString *const kAppFingerPrint = @"com.yoho.appfingerprint";
  22 +
21 @interface YHDevice () 23 @interface YHDevice ()
22 24
23 @property (copy, nonatomic) NSString *sv; // 采集数据sdk的版本 25 @property (copy, nonatomic) NSString *sv; // 采集数据sdk的版本
@@ -29,6 +31,7 @@ @@ -29,6 +31,7 @@
29 @property (copy, nonatomic) NSString *ifv; // ifv 31 @property (copy, nonatomic) NSString *ifv; // ifv
30 @property (copy, nonatomic) NSString *res; // 分辨率 32 @property (copy, nonatomic) NSString *res; // 分辨率
31 @property (copy, nonatomic) NSString *mac; // Mac地址 33 @property (copy, nonatomic) NSString *mac; // Mac地址
  34 +@property (copy, nonatomic) NSString *afp; // app安装指纹(40位随机数)
32 35
33 @end 36 @end
34 37
@@ -66,6 +69,8 @@ @@ -66,6 +69,8 @@
66 self.ifa = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString]; 69 self.ifa = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];
67 70
68 self.mac = [YHDevice getMacAddress]; 71 self.mac = [YHDevice getMacAddress];
  72 +
  73 + self.afp = [YHDevice getAppFingerPrint];
69 } 74 }
70 75
71 return self; 76 return self;
@@ -85,6 +90,7 @@ @@ -85,6 +90,7 @@
85 JsonKeyDeviceIFV : self.ifv ? self.ifv : @"", 90 JsonKeyDeviceIFV : self.ifv ? self.ifv : @"",
86 JsonKeyDeviceRES : self.res ? self.res : @"", 91 JsonKeyDeviceRES : self.res ? self.res : @"",
87 JsonKeyDeviceMAC : self.mac ? self.mac : @"", 92 JsonKeyDeviceMAC : self.mac ? self.mac : @"",
  93 + JsonKeyDeviceAFP : self.afp ? self.afp : @""
88 }; 94 };
89 } 95 }
90 96
@@ -153,4 +159,16 @@ @@ -153,4 +159,16 @@
153 return macAddressString; 159 return macAddressString;
154 } 160 }
155 161
  162 ++ (NSString *)getAppFingerPrint
  163 +{
  164 + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
  165 + NSString *fpString = [defaults objectForKey:kAppFingerPrint];
  166 + if (fpString == nil || ![fpString isKindOfClass:[NSString class]] || fpString.length != 40) {
  167 + fpString = [OpenUDID _generateFreshOpenUDID];
  168 + [defaults setObject:fpString forKey:kAppFingerPrint];
  169 + [defaults synchronize];
  170 + }
  171 + return fpString;
  172 +}
  173 +
156 @end 174 @end
@@ -65,5 +65,5 @@ @@ -65,5 +65,5 @@
65 + (BOOL) isNewDevice; 65 + (BOOL) isNewDevice;
66 + (void) setFirstLaunch; 66 + (void) setFirstLaunch;
67 + (BOOL) isFirstLaunch; 67 + (BOOL) isFirstLaunch;
68 - 68 ++ (NSString*) _generateFreshOpenUDID;
69 @end 69 @end
@@ -77,7 +77,6 @@ static NSString * const kYohoBuyFirstLaunch = @"firstlaunch"; @@ -77,7 +77,6 @@ static NSString * const kYohoBuyFirstLaunch = @"firstlaunch";
77 @interface OpenUDID (Private) 77 @interface OpenUDID (Private)
78 + (void) _setDict:(id)dict forPasteboard:(id)pboard; 78 + (void) _setDict:(id)dict forPasteboard:(id)pboard;
79 + (NSMutableDictionary*) _getDictFromPasteboard:(id)pboard; 79 + (NSMutableDictionary*) _getDictFromPasteboard:(id)pboard;
80 -+ (NSString*) _generateFreshOpenUDID;  
81 @end 80 @end
82 81
83 @implementation OpenUDID 82 @implementation OpenUDID
@@ -86,6 +86,7 @@ @@ -86,6 +86,7 @@
86 #define JsonKeyDeviceIFV @"ifv" // idfv 86 #define JsonKeyDeviceIFV @"ifv" // idfv
87 #define JsonKeyDeviceRES @"res" // 分辨率 87 #define JsonKeyDeviceRES @"res" // 分辨率
88 #define JsonKeyDeviceMAC @"mac" // Mac地址 88 #define JsonKeyDeviceMAC @"mac" // Mac地址
  89 +#define JsonKeyDeviceAFP @"afp" // app安装指纹
89 90
90 // 状态参数 91 // 状态参数
91 #define JsonKeyStatusAV @"av" // App版本号 92 #define JsonKeyStatusAV @"av" // App版本号