Authored by 朱小军

将JTSHardwareInfo挪到大数据上报中 review by haizi

Pod::Spec.new do |s|
s.name = "YH_Analytics"
s.version = "1.0.1"
s.version = "1.1"
s.summary = "Analytics Kit"
s.description = <<-DESC
Analytics Kit
... ... @@ -43,6 +43,11 @@ Pod::Spec.new do |s|
ss.requires_arc = true
end
s.subspec 'JTSHardwareInfo' do |ss|
ss.source_files = 'YH_Analytics/YH_Analytics/YH_Analytics/YHAnalyticsDependencies/JTSHardwareInfo/*.{h,m}'
ss.requires_arc = true
end
s.frameworks = 'Foundation', 'CoreGraphics', 'UIKit'
end
... ...
... ... @@ -7,6 +7,7 @@
objects = {
/* Begin PBXBuildFile section */
047381071EADEE970007E850 /* JTSHardwareInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 047381061EADEE970007E850 /* JTSHardwareInfo.m */; };
0928E56C1E8D3824008FD4F3 /* YHPatch.m in Sources */ = {isa = PBXBuildFile; fileRef = 0928E56B1E8D3824008FD4F3 /* YHPatch.m */; };
194EDC761A7F52D100421E6C /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 194EDC751A7F52D100421E6C /* main.m */; };
194EDC791A7F52D100421E6C /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 194EDC781A7F52D100421E6C /* AppDelegate.m */; };
... ... @@ -102,6 +103,8 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
047381051EADEE970007E850 /* JTSHardwareInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JTSHardwareInfo.h; sourceTree = "<group>"; };
047381061EADEE970007E850 /* JTSHardwareInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JTSHardwareInfo.m; sourceTree = "<group>"; };
0928E56A1E8D3824008FD4F3 /* YHPatch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YHPatch.h; sourceTree = "<group>"; };
0928E56B1E8D3824008FD4F3 /* YHPatch.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YHPatch.m; sourceTree = "<group>"; };
194EDC701A7F52D100421E6C /* YH_Analytics.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = YH_Analytics.app; sourceTree = BUILT_PRODUCTS_DIR; };
... ... @@ -256,6 +259,15 @@
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
047381041EADEE970007E850 /* JTSHardwareInfo */ = {
isa = PBXGroup;
children = (
047381051EADEE970007E850 /* JTSHardwareInfo.h */,
047381061EADEE970007E850 /* JTSHardwareInfo.m */,
);
path = JTSHardwareInfo;
sourceTree = "<group>";
};
194EDC671A7F52D100421E6C = {
isa = PBXGroup;
children = (
... ... @@ -504,6 +516,7 @@
E7B8DE261A81DCBD00102CC4 /* YHAnalyticsDependencies */ = {
isa = PBXGroup;
children = (
047381041EADEE970007E850 /* JTSHardwareInfo */,
E74D458C1ABA7C6300EFE12E /* AFNetworking */,
E7B8DE471A81EE0A00102CC4 /* OpenUDID */,
);
... ... @@ -696,6 +709,7 @@
E74D45C01ABA7C6300EFE12E /* UIProgressView+AFNetworking.m in Sources */,
E7ADAE551AB94EBD00C9DD0B /* YHEventFactory.m in Sources */,
E7A908731BB3C4B000E2EA39 /* YHPerformance.m in Sources */,
047381071EADEE970007E850 /* JTSHardwareInfo.m in Sources */,
E7ADAE3B1AB946C100C9DD0B /* YHDevice.m in Sources */,
E79828121AA6A5120035137C /* YH_KeychainStore.m in Sources */,
0928E56C1E8D3824008FD4F3 /* YHPatch.m in Sources */,
... ...
... ... @@ -15,7 +15,7 @@
#import <UIKit/UIKit.h>
#import <AdSupport/AdSupport.h>
#import "OpenUDID.h"
#import "JTSHardwareInfo.h"
#import "YHDevice.h"
static NSString *const kAppFingerPrint = @"com.yoho.appfingerprint";
... ... @@ -55,7 +55,7 @@ static NSString *const kAppFingerPrint = @"com.yoho.appfingerprint";
self.osv = @"Unknown";
}
self.dm = [[UIDevice currentDevice] model];
self.dm = [JTSHardwareInfo hardwareDisplayName];
CGRect rect = [[UIScreen mainScreen] bounds];
CGFloat scale = [[UIScreen mainScreen] scale];
... ...
... ... @@ -12,7 +12,7 @@
#include <sys/sysctl.h>
#import <CoreGraphics/CoreGraphics.h>
#import <UIKit/UIKit.h>
#import "JTSHardwareInfo.h"
#define kUDIDMD5Suffix @"yohoeeohoy"
... ... @@ -77,64 +77,6 @@
return platform;
}
+ (NSString *)deviceModel
{
NSString *platform = [self devicePlatform];
if ([platform isEqualToString:@"iPhone1,1"]) return @"iPhone 2G (A1203)";
if ([platform isEqualToString:@"iPhone1,2"]) return @"iPhone 3G (A1241/A1324)";
if ([platform isEqualToString:@"iPhone2,1"]) return @"iPhone 3GS (A1303/A1325)";
if ([platform isEqualToString:@"iPhone3,1"]) return @"iPhone 4 (A1332)";
if ([platform isEqualToString:@"iPhone3,2"]) return @"iPhone 4 (A1332)";
if ([platform isEqualToString:@"iPhone3,3"]) return @"iPhone 4 (A1349)";
if ([platform isEqualToString:@"iPhone4,1"]) return @"iPhone 4S (A1387/A1431)";
if ([platform isEqualToString:@"iPhone5,1"]) return @"iPhone 5 (A1428)";
if ([platform isEqualToString:@"iPhone5,2"]) return @"iPhone 5 (A1429/A1442)";
if ([platform isEqualToString:@"iPhone5,3"]) return @"iPhone 5c (A1456/A1532)";
if ([platform isEqualToString:@"iPhone5,4"]) return @"iPhone 5c (A1507/A1516/A1526/A1529)";
if ([platform isEqualToString:@"iPhone6,1"]) return @"iPhone 5s (A1453/A1533)";
if ([platform isEqualToString:@"iPhone6,2"]) return @"iPhone 5s (A1457/A1518/A1528/A1530)";
if ([platform isEqualToString:@"iPhone7,1"]) return @"iPhone 6 Plus (A1522/A1524)";
if ([platform isEqualToString:@"iPhone7,2"]) return @"iPhone 6 (A1549/A1586)";
if ([platform isEqualToString:@"iPod1,1"]) return @"iPod Touch 1G (A1213)";
if ([platform isEqualToString:@"iPod2,1"]) return @"iPod Touch 2G (A1288)";
if ([platform isEqualToString:@"iPod3,1"]) return @"iPod Touch 3G (A1318)";
if ([platform isEqualToString:@"iPod4,1"]) return @"iPod Touch 4G (A1367)";
if ([platform isEqualToString:@"iPod5,1"]) return @"iPod Touch 5G (A1421/A1509)";
if ([platform isEqualToString:@"iPad1,1"]) return @"iPad 1G (A1219/A1337)";
if ([platform isEqualToString:@"iPad2,1"]) return @"iPad 2 (A1395)";
if ([platform isEqualToString:@"iPad2,2"]) return @"iPad 2 (A1396)";
if ([platform isEqualToString:@"iPad2,3"]) return @"iPad 2 (A1397)";
if ([platform isEqualToString:@"iPad2,4"]) return @"iPad 2 (A1395+New Chip)";
if ([platform isEqualToString:@"iPad2,5"]) return @"iPad Mini 1G (A1432)";
if ([platform isEqualToString:@"iPad2,6"]) return @"iPad Mini 1G (A1454)";
if ([platform isEqualToString:@"iPad2,7"]) return @"iPad Mini 1G (A1455)";
if ([platform isEqualToString:@"iPad3,1"]) return @"iPad 3 (A1416)";
if ([platform isEqualToString:@"iPad3,2"]) return @"iPad 3 (A1403)";
if ([platform isEqualToString:@"iPad3,3"]) return @"iPad 3 (A1430)";
if ([platform isEqualToString:@"iPad3,4"]) return @"iPad 4 (A1458)";
if ([platform isEqualToString:@"iPad3,5"]) return @"iPad 4 (A1459)";
if ([platform isEqualToString:@"iPad3,6"]) return @"iPad 4 (A1460)";
if ([platform isEqualToString:@"iPad4,1"]) return @"iPad Air (A1474)";
if ([platform isEqualToString:@"iPad4,2"]) return @"iPad Air (A1475)";
if ([platform isEqualToString:@"iPad4,3"]) return @"iPad Air (A1476)";
if ([platform isEqualToString:@"iPad4,4"]) return @"iPad Mini 2G (A1489)";
if ([platform isEqualToString:@"iPad4,5"]) return @"iPad Mini 2G (A1490)";
if ([platform isEqualToString:@"iPad4,6"]) return @"iPad Mini 2G (A1491)";
if ([platform isEqualToString:@"i386"]) return @"iPhone Simulator";
if ([platform isEqualToString:@"x86_64"]) return @"iPhone Simulator";
return platform;
}
+ (NSString *)screenResolution
{
CGRect rect = [[UIScreen mainScreen] bounds];
... ... @@ -164,11 +106,9 @@
return [NSString stringWithFormat:@"%lld", date];
}
+ (NSString *)userAgent
{
return [NSString stringWithFormat:@"%@,%@,%@,%@,%@,%@,%@,%@",[self openUDID], [self timestamp], [self md5UDID], [self deviceModel], [self screenResolution], [self operatingSystemNameAndVersion], [self applicationNameAndVersion], [self timeZone]];
return [NSString stringWithFormat:@"%@,%@,%@,%@,%@,%@,%@,%@",[self openUDID], [self timestamp], [self md5UDID], [JTSHardwareInfo hardwareDisplayName], [self screenResolution], [self operatingSystemNameAndVersion], [self applicationNameAndVersion], [self timeZone]];
}
... ...
//
// JTSHardwareInfo.h
// JTSHardwareInfo
//
// Created by Jared Sinclair on 10/1/14.
// Copyright (c) 2014 Nice Boy LLC. All rights reserved.
//
// Originally based on code by InderKumarRathmore at https://github.com/InderKumarRathore/UIDevice-Hardware
//
@import UIKit;
@interface JTSHardwareInfo : NSObject
typedef NS_ENUM(NSInteger, JTSHardwareFamily) {
JTSHardwareFamily_Unknown,
JTSHardwareFamily_iPhone,
JTSHardwareFamily_iPad,
JTSHardwareFamily_iPodTouch,
};
typedef NS_ENUM(NSInteger, JTSHardwareType) {
JTSHardwareType_NotAvailable,
JTSHardwareType_Simulator,
JTSHardwareType_iPhone_Unreleased,
JTSHardwareType_iPodTouch_Unreleased,
JTSHardwareType_iPad_Unreleased,
JTSHardwareType_iPhone,
JTSHardwareType_iPhone_3G,
JTSHardwareType_iPhone_3G_China,
JTSHardwareType_iPhone_3GS,
JTSHardwareType_iPhone_3GS_China,
JTSHardwareType_iPhone_4_GSM,
JTSHardwareType_iPhone_4_GSM_2012,
JTSHardwareType_iPhone_4_CDMA,
JTSHardwareType_iPhone_4S,
JTSHardwareType_iPhone_4S_China,
JTSHardwareType_iPhone_5_GSM,
JTSHardwareType_iPhone_5_Global,
JTSHardwareType_iPhone_5C_GSM,
JTSHardwareType_iPhone_5C_Global,
JTSHardwareType_iPhone_5S_GSM,
JTSHardwareType_iPhone_5S_Global,
JTSHardwareType_iPhone_6,
JTSHardwareType_iPhone_6_China,
JTSHardwareType_iPhone_6Plus,
JTSHardwareType_iPhone_6Plus_China,
JTSHardwareType_iPhone_6S,
JTSHardwareType_iPhone_6S_Plus,
JTSHardwareType_iPhone_7,
JTSHardwareType_iPhone_7_Plus,
JTSHardwareType_iPodTouch_1Gen,
JTSHardwareType_iPodTouch_2Gen,
JTSHardwareType_iPodTouch_3Gen,
JTSHardwareType_iPodTouch_4Gen,
JTSHardwareType_iPodTouch_5Gen,
JTSHardwareType_iPad,
JTSHardwareType_iPad_Cellular,
JTSHardwareType_iPad_2_WiFi,
JTSHardwareType_iPad_2_GSM,
JTSHardwareType_iPad_2_CDMA,
JTSHardwareType_iPad_2_Mid_2012,
JTSHardwareType_iPad_3_WiFi,
JTSHardwareType_iPad_3_GSM,
JTSHardwareType_iPad_3_CDMA,
JTSHardwareType_iPad_4_WiFi,
JTSHardwareType_iPad_4_GSM,
JTSHardwareType_iPad_4_Global,
JTSHardwareType_iPad_Air_WiFi,
JTSHardwareType_iPad_Air_Cellular,
JTSHardwareType_iPad_Air_China,
JTSHardwareType_iPad_Mini_WiFi,
JTSHardwareType_iPad_Mini_GSM,
JTSHardwareType_iPad_Mini_Global,
JTSHardwareType_iPad_Mini_Retina_WiFi,
JTSHardwareType_iPad_Mini_Retina_Cellular,
JTSHardwareType_iPad_Mini_Retina_China,
};
+ (NSString *)hardwareIdentifier;
+ (JTSHardwareType)hardwareType;
+ (JTSHardwareFamily)hardwareFamily;
+ (NSString *)hardwareDisplayName;
+ (BOOL)airDropIsAvailable;
@end
... ...
//
// JTSHardwareInfo.m
// JTSHardwareInfo
//
// Created by Jared Sinclair on 10/1/14.
// Copyright (c) 2014 Nice Boy LLC. All rights reserved.
//
#import "JTSHardwareInfo.h"
#include <sys/types.h>
#include <sys/sysctl.h>
static NSString * JTSHardwareInfo_HardwareIdentifier_iPhone = @"iPhone1,1";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPhone_3G = @"iPhone1,2";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPhone_3G_China = @"iPhone1,2*";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPhone_3GS = @"iPhone2,1";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPhone_3GS_China = @"iPhone2,1*";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPhone_4_GSM = @"iPhone3,1";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPhone_4_GSM_2012 = @"iPhone3,2";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPhone_4_CDMA = @"iPhone3,3";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPhone_4S = @"iPhone4,1";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPhone_4S_China = @"iPhone4,1*";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPhone_5_GSM = @"iPhone5,1";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPhone_5_Global = @"iPhone5,2";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPhone_5C_GSM = @"iPhone5,3";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPhone_5C_Global = @"iPhone5,4";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPhone_5S_GSM = @"iPhone6,1";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPhone_5S_Global = @"iPhone6,2";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPhone_6Plus_China = @"iPhone7,1*";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPhone_6Plus = @"iPhone7,1";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPhone_6_China = @"iPhone7,2*";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPhone_6 = @"iPhone7,2";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPhone_6S_Plus = @"iPhone8,2";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPhone_6S = @"iPhone8,1";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPhone_7_Plus = @"iPhone9,2";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPhone_7 = @"iPhone9,1";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPad = @"iPad1,1";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPad_Cellular = @"iPad1,2";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPad_2_WiFi = @"iPad2,1";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPad_2_GSM = @"iPad2,2";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPad_2_CDMA = @"iPad2,3";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPad_2_MID_2012 = @"iPad2,4";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPad_Mini_WiFi = @"iPad2,5";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPad_Mini_GSM = @"iPad2,6";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPad_Mini_Global = @"iPad2,7";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPad_3_WiFi = @"iPad3,1";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPad_3_CDMA = @"iPad3,2";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPad_3_GSM = @"iPad3,3";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPad_4_WiFi = @"iPad3,4";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPad_4_GSM = @"iPad3,5";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPad_4_Global = @"iPad3,6";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPad_Air_WiFi = @"iPad4,1";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPad_Air_Cellular = @"iPad4,2";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPad_Air_China = @"iPad4,3";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPad_Mini_Retina_WiFi = @"iPad4,4";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPad_Mini_Retina_Cellular = @"iPad4,5";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPad_Mini_Retina_China = @"iPad4,6";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPodTouch_1G = @"iPod1,1";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPodTouch_2G = @"iPod2,1";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPodTouch_3G = @"iPod3,1";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPodTouch_4G = @"iPod4,1";
static NSString * JTSHardwareInfo_HardwareIdentifier_iPodTouch_5G = @"iPod5,1";
@implementation JTSHardwareInfo
#pragma mark - Public
+ (NSString *)hardwareIdentifier {
static dispatch_once_t once;
static NSString * hardware;
dispatch_once(&once, ^ {
size_t size = 100;
char *hw_machine = malloc(size);
int name[] = {CTL_HW,HW_MACHINE};
sysctl(name, 2, hw_machine, &size, NULL, 0);
hardware = [NSString stringWithUTF8String:hw_machine];
free(hw_machine);
});
return hardware;
}
+ (JTSHardwareFamily)hardwareFamily {
static dispatch_once_t once;
static JTSHardwareFamily family;
dispatch_once(&once, ^ {
NSString *deviceName = [UIDevice currentDevice].name;
if ([deviceName hasPrefix:@"iPhone"]) {
family = JTSHardwareFamily_iPhone;
}
else if ([deviceName hasPrefix:@"iPad"]) {
family = JTSHardwareFamily_iPad;
}
else if ([deviceName hasPrefix:@"iPod"]) {
family = JTSHardwareFamily_iPodTouch;
}
else {
family = JTSHardwareFamily_Unknown;
}
});
return family;
}
+ (JTSHardwareType)hardwareType {
static dispatch_once_t once;
static JTSHardwareType type;
dispatch_once(&once, ^ {
type = [self getCurrentHardwareType];
});
return type;
}
+ (NSString *)hardwareDisplayName {
NSString *displayName = nil;
switch ([self hardwareType]) {
case JTSHardwareType_Simulator:
displayName = @"iOS Simulator";
break;
case JTSHardwareType_NotAvailable:
case JTSHardwareType_iPhone_Unreleased:
case JTSHardwareType_iPad_Unreleased:
case JTSHardwareType_iPodTouch_Unreleased:
displayName = [[UIDevice currentDevice] name];
break;
case JTSHardwareType_iPhone_7_Plus:
displayName = @"iPhone 7 Plus";
break;
case JTSHardwareType_iPhone_7:
displayName = @"iPhone 7";
break;
case JTSHardwareType_iPhone_6S:
displayName = @"iPhone 6S";
break;
case JTSHardwareType_iPhone_6S_Plus:
displayName = @"iPhone 6S Plus";
break;
case JTSHardwareType_iPhone_6_China:
displayName = @"iPhone 6 (China)";
break;
case JTSHardwareType_iPhone_6:
displayName = @"iPhone 6";
break;
case JTSHardwareType_iPhone_6Plus_China:
displayName = @"iPhone 6 Plus (China)";
break;
case JTSHardwareType_iPhone_6Plus:
displayName = @"iPhone 6 Plus";
break;
case JTSHardwareType_iPhone_5S_Global:
displayName = @"iPhone 5s (Global)";
break;
case JTSHardwareType_iPhone_5S_GSM:
displayName = @"iPhone 5s (GSM)";
break;
case JTSHardwareType_iPhone_5C_Global:
displayName = @"iPhone 5c (Global)";
break;
case JTSHardwareType_iPhone_5C_GSM:
displayName = @"iPhone 5c (GSM)";
break;
case JTSHardwareType_iPhone_5_Global:
displayName = @"iPhone 5 (Global)";
break;
case JTSHardwareType_iPhone_5_GSM:
displayName = @"iPhone 5 (GSM)";
break;
case JTSHardwareType_iPhone_4S_China:
displayName = @"iPhone 4S (China)";
break;
case JTSHardwareType_iPhone_4S:
displayName = @"iPhone 4S";
break;
case JTSHardwareType_iPhone_4_GSM_2012:
displayName = @"iPhone 4 (GSM 2012)";
break;
case JTSHardwareType_iPhone_4_CDMA:
displayName = @"iPhone 4 (CDMA)";
break;
case JTSHardwareType_iPhone_4_GSM:
displayName = @"iPhone 4 (GSM)";
break;
case JTSHardwareType_iPhone_3GS:
displayName = @"iPhone 3GS";
break;
case JTSHardwareType_iPhone_3GS_China:
displayName = @"iPhone 3GS (China/No WiFi)";
break;
case JTSHardwareType_iPhone_3G:
displayName = @"iPhone 3G";
break;
case JTSHardwareType_iPhone_3G_China:
displayName = @"iPhone 3G (China/No WiFi)";
break;
case JTSHardwareType_iPhone:
displayName = @"iPhone";
break;
case JTSHardwareType_iPad_Mini_Retina_China:
displayName = @"iPad Mini Retina (China)";
break;
case JTSHardwareType_iPad_Mini_Retina_Cellular:
displayName = @"iPad Mini Retina (Cellular)";
break;
case JTSHardwareType_iPad_Mini_Retina_WiFi:
displayName = @"iPad Mini Retina (WiFi)";
break;
case JTSHardwareType_iPad_Mini_Global:
displayName = @"iPad Mini (Global)";
break;
case JTSHardwareType_iPad_Mini_GSM:
displayName = @"iPad Mini (GSM)";
break;
case JTSHardwareType_iPad_Mini_WiFi:
displayName = @"iPad Mini (WiFi)";
break;
case JTSHardwareType_iPad_Air_China:
displayName = @"iPad Air (China)";
break;
case JTSHardwareType_iPad_Air_Cellular:
displayName = @"iPad Air (Cellular)";
break;
case JTSHardwareType_iPad_Air_WiFi:
displayName = @"iPad Air (WiFi)";
break;
case JTSHardwareType_iPad_4_Global:
displayName = @"iPad 4 (Global)";
break;
case JTSHardwareType_iPad_4_GSM:
displayName = @"iPad 4 (GSM)";
break;
case JTSHardwareType_iPad_4_WiFi:
displayName = @"iPad 4 (WiFi)";
break;
case JTSHardwareType_iPad_3_CDMA:
displayName = @"iPad 3 (CDMA)";
break;
case JTSHardwareType_iPad_3_GSM:
displayName = @"iPad 3 (GSM)";
break;
case JTSHardwareType_iPad_3_WiFi:
displayName = @"iPad 3 (WiFi)";
break;
case JTSHardwareType_iPad_2_Mid_2012:
displayName = @"iPad 2 (Mid 2012)";
break;
case JTSHardwareType_iPad_2_CDMA:
displayName = @"iPad 2 (CDMA)";
break;
case JTSHardwareType_iPad_2_GSM:
displayName = @"iPad (GSM)";
break;
case JTSHardwareType_iPad_2_WiFi:
displayName = @"iPad 2 (WiFi)";
break;
case JTSHardwareType_iPad_Cellular:
displayName = @"iPad (Cellular)";
break;
case JTSHardwareType_iPad:
displayName = @"iPad";
break;
case JTSHardwareType_iPodTouch_5Gen:
displayName = @"iPod Touch (5th Gen)";
break;
case JTSHardwareType_iPodTouch_4Gen:
displayName = @"iPod Touch (4th Gen)";
break;
case JTSHardwareType_iPodTouch_3Gen:
displayName = @"iPod Touch (3rd Gen)";
break;
case JTSHardwareType_iPodTouch_2Gen:
displayName = @"iPod Touch (2nd Gen)";
break;
case JTSHardwareType_iPodTouch_1Gen:
displayName = @"iPod Touch (1st Gen)";
break;
default:
displayName = @"Not Available";
break;
}
return displayName;
}
+ (BOOL)airDropIsAvailable {
static dispatch_once_t once;
static BOOL isAvailable;
dispatch_once(&once, ^ {
JTSHardwareType hardwareType = [self hardwareType];
if (hardwareType == JTSHardwareType_NotAvailable) {
isAvailable = YES;
}
else if (hardwareType == JTSHardwareType_iPhone_Unreleased) {
isAvailable = YES;
}
else if (hardwareType == JTSHardwareType_iPad_Unreleased) {
isAvailable = YES;
}
else if (hardwareType == JTSHardwareType_iPodTouch_Unreleased) {
isAvailable = YES;
}
else {
NSString *hardwareString = [self hardwareIdentifier];
if ([hardwareString hasPrefix:@"iPhone"]) {
isAvailable = (hardwareType >= JTSHardwareType_iPhone_5_GSM);
}
else if ([hardwareString hasPrefix:@"iPad"]) {
isAvailable = (hardwareType >= JTSHardwareType_iPad_4_WiFi);
}
else if ([hardwareString hasPrefix:@"iPod"]) {
isAvailable = (hardwareType >= JTSHardwareType_iPodTouch_5Gen);
}
}
});
return isAvailable;
}
#pragma mark - Private
+ (JTSHardwareType)getCurrentHardwareType {
NSString *hardware = [self hardwareIdentifier];
if ([hardware hasPrefix:@"iPhone"]) {
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPhone_7]) return JTSHardwareType_iPhone_7;
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPhone_7_Plus]) return JTSHardwareType_iPhone_7_Plus;
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPhone_6S]) return JTSHardwareType_iPhone_6S;
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPhone_6S_Plus]) return JTSHardwareType_iPhone_6S_Plus;
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPhone_6_China]) return JTSHardwareType_iPhone_6_China;
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPhone_6]) return JTSHardwareType_iPhone_6;
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPhone_6Plus_China]) return JTSHardwareType_iPhone_6Plus_China;
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPhone_6Plus]) return JTSHardwareType_iPhone_6Plus;
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPhone_5S_Global]) return JTSHardwareType_iPhone_5S_Global;
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPhone_5S_GSM]) return JTSHardwareType_iPhone_5S_GSM;
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPhone_5C_Global]) return JTSHardwareType_iPhone_5C_Global;
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPhone_5C_GSM]) return JTSHardwareType_iPhone_5C_GSM;
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPhone_5_Global]) return JTSHardwareType_iPhone_5_Global;
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPhone_5_GSM]) return JTSHardwareType_iPhone_5_GSM;
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPhone_4S_China]) return JTSHardwareType_iPhone_4S_China;
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPhone_4S]) return JTSHardwareType_iPhone_4S;
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPhone_4_CDMA]) return JTSHardwareType_iPhone_4_CDMA;
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPhone_4_GSM_2012]) return JTSHardwareType_iPhone_4_GSM_2012;
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPhone_4_GSM]) return JTSHardwareType_iPhone_4_GSM;
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPhone_3GS_China]) return JTSHardwareType_iPhone_3GS_China;
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPhone_3GS]) return JTSHardwareType_iPhone_3GS;
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPhone_3G_China]) return JTSHardwareType_iPhone_3G_China;
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPhone_3G]) return JTSHardwareType_iPhone_3G;
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPhone]) return JTSHardwareType_iPhone;
return JTSHardwareType_iPhone_Unreleased;
}
else if ([hardware hasPrefix:@"iPad"]) {
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPad_Mini_Retina_China]) return JTSHardwareType_iPad_Mini_Retina_China;
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPad_Mini_Retina_Cellular])return JTSHardwareType_iPad_Mini_Retina_Cellular;
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPad_Mini_Retina_WiFi]) return JTSHardwareType_iPad_Mini_Retina_WiFi;
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPad_Mini_Global]) return JTSHardwareType_iPad_Mini_Global;
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPad_Mini_GSM]) return JTSHardwareType_iPad_Mini_GSM;
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPad_Mini_WiFi]) return JTSHardwareType_iPad_Mini_WiFi;
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPad_Air_China]) return JTSHardwareType_iPad_Air_China;
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPad_Air_Cellular]) return JTSHardwareType_iPad_Air_Cellular;
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPad_Air_WiFi]) return JTSHardwareType_iPad_Air_WiFi;
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPad_4_Global]) return JTSHardwareType_iPad_4_Global;
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPad_4_GSM]) return JTSHardwareType_iPad_4_GSM;
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPad_4_WiFi]) return JTSHardwareType_iPad_4_WiFi;
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPad_3_CDMA]) return JTSHardwareType_iPad_3_CDMA;
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPad_3_GSM]) return JTSHardwareType_iPad_3_GSM;
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPad_3_WiFi]) return JTSHardwareType_iPad_3_WiFi;
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPad_2_MID_2012]) return JTSHardwareType_iPad_2_Mid_2012;
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPad_2_CDMA]) return JTSHardwareType_iPad_2_CDMA;
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPad_2_GSM]) return JTSHardwareType_iPad_2_GSM;
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPad_2_WiFi]) return JTSHardwareType_iPad_2_WiFi;
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPad_Cellular]) return JTSHardwareType_iPad_Cellular;
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPad]) return JTSHardwareType_iPad;
return JTSHardwareType_iPad_Unreleased;
}
else if ([hardware hasPrefix:@"iPod"]) {
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPodTouch_5G]) return JTSHardwareType_iPodTouch_5Gen;
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPodTouch_4G]) return JTSHardwareType_iPodTouch_4Gen;
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPodTouch_3G]) return JTSHardwareType_iPodTouch_3Gen;
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPodTouch_2G]) return JTSHardwareType_iPodTouch_2Gen;
if ([hardware isEqualToString:JTSHardwareInfo_HardwareIdentifier_iPodTouch_1G]) return JTSHardwareType_iPodTouch_1Gen;
return JTSHardwareType_iPodTouch_Unreleased;
}
if ([hardware isEqualToString:@"i386"]) return JTSHardwareType_Simulator;
if ([hardware isEqualToString:@"x86_64"]) return JTSHardwareType_Simulator;
return JTSHardwareType_NotAvailable;
}
@end
... ...