Authored by 刘金林

ca info

... ... @@ -300,6 +300,7 @@ typedef NS_ENUM(NSInteger, YHPointType) {
#define kCarrierCodeChinaTelecom @"2" // 中国电信
#define kCarrierCodeChinaUnicom @"3" // 中国联通
#define kCarrierCodeChinaTietong @"4" // 中国铁通
#define kCarrierCodeOverseas @"5" // 海外
//上报参数的key
#define YOHOAppReportKeyAK @"ak"
... ... @@ -320,7 +321,8 @@ typedef NS_ENUM(NSInteger, YHPointType) {
#define YOHOAppReportKeyPT @"pt"
#define YOHOAppReportKeyPN @"pn"
#define YOHOAppReportKeyPARAM @"param"
#define YOHOAppReportKeyMCC @"mcc"
#define YOHOAppReportKeyMNC @"mnc"
#define YOHOAppReportDefaultAPPKey @"yohobuy_ios"
... ...
... ... @@ -134,6 +134,8 @@
IsStrEmpty(appInfo.ts)?@"":appInfo.ts,YOHOAppReportKeyTS,
IsStrEmpty(appInfo.uid)?@"":appInfo.uid,YOHOAppReportKeyUID,
IsStrEmpty(appInfo.sid)?@"":appInfo.sid,YOHOAppReportKeySID,
IsStrEmpty(appInfo.mcc)?@"":appInfo.mcc,YOHOAppReportKeyMCC,
IsStrEmpty(appInfo.mnc)?@"":appInfo.mnc,YOHOAppReportKeyMNC,
nil];
return commonInfo;
}
... ...
... ... @@ -25,6 +25,8 @@
@property (copy, nonatomic) NSString *sid; // 会话id(由设备标识和启动时间戳做md5)
@property (copy, nonatomic) NSString *ts; // 时间戳
@property (copy, nonatomic) NSString *idfa; //设备idfa标识
@property (copy, nonatomic) NSString *mcc; //移动设备国家代码(Mobile Country Code,MCC)
@property (copy, nonatomic) NSString *mnc; //运营商码 移动设备网络代码英语:Mobile Network Code,MNC
-(void)resetSessionID;
... ...
... ... @@ -26,8 +26,8 @@
self = [super init];
if (self) {
self.ps = @"0";
self.ca = [self getCurrentCa];
self.idfa = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];
[self loadCarrierInfo];
}
return self;
... ... @@ -39,6 +39,13 @@
}
}
- (NSString *)ca {
if (!_ca || [_ca isEqualToString:kCarrierCodeChinaUnknown]) {
[self loadCarrierInfo];
}
return _ca;
}
- (NSString*)ch
{
_ch = [[YHEventReport sharedInstance] channelId];
... ... @@ -125,23 +132,40 @@
return _net;
}
- (NSString *)getCurrentCa
- (void)loadCarrierInfo
{
NSString *currentCa = kCarrierCodeChinaUnknown;
CTTelephonyNetworkInfo *netInfo = [[CTTelephonyNetworkInfo alloc] init];
CTCarrier *carrier = [netInfo subscriberCellularProvider];
// 中国移动
if ([carrier.mobileNetworkCode isEqualToString:@"00"] || [carrier.mobileNetworkCode isEqualToString:@"02"] || [carrier.mobileNetworkCode isEqualToString:@"07"]) {
return kCarrierCodeChinaMobile;
} else if([carrier.mobileNetworkCode isEqualToString:@"01"] || [carrier.mobileNetworkCode isEqualToString:@"06"]) { // 中国联通
return kCarrierCodeChinaUnicom;
}else if([carrier.mobileNetworkCode isEqualToString:@"03"] || [carrier.mobileNetworkCode isEqualToString:@"05"]) { // 中国电信
return kCarrierCodeChinaTelecom;
} else if([carrier.mobileNetworkCode isEqualToString:@"20"]){ // 中国铁通
return kCarrierCodeChinaTietong;
NSString *const chinaMCC = @"460";
_mcc = [carrier.mobileCountryCode copy] ?: @"";
_mnc = [carrier.mobileNetworkCode copy] ?: @"";
if (carrier.mobileCountryCode) {
if ([carrier.mobileCountryCode isEqualToString:chinaMCC]) {
NSArray *const chinaMobile = @[ @"00", @"02", @"07" ];// 中国移动
NSArray *const chinaUnicom = @[ @"01", @"06", @"09" ];// 中国联通
NSArray *const chinaTelecom = @[ @"03", @"05", @"11" ];// 中国电信
NSArray *const chinaTietong = @[ @"20" ];// 中国铁通
NSString *const mnc = [carrier.mobileNetworkCode copy];
if ([chinaMobile containsObject:mnc]) {
currentCa = kCarrierCodeChinaMobile;
} else if ([chinaUnicom containsObject:mnc]) {
currentCa = kCarrierCodeChinaUnicom;
} else if ([chinaTelecom containsObject:mnc]) {
currentCa = kCarrierCodeChinaTelecom;
} else if ([chinaTietong containsObject:mnc]) {
currentCa = kCarrierCodeChinaTietong;
}
} else {
currentCa = kCarrierCodeOverseas;
}
}
if ([currentCa isEqualToString:kCarrierCodeChinaUnknown]) {
currentCa = [[NSUserDefaults standardUserDefaults] objectForKey:NSStringFromSelector(_cmd)] ?: kCarrierCodeChinaUnknown;
} else {
return kCarrierCodeChinaUnknown;
[[NSUserDefaults standardUserDefaults] setObject:currentCa forKey:NSStringFromSelector(_cmd)];
}
_ca = [currentCa copy];
}
-(NSString *)uid{
... ...
... ... @@ -52,7 +52,7 @@ static NSString *kParamKeyType = @"type";
if (self) {
self.timeInterval = 30;
self.mode = YHEventReportStrategyInterval;
self.performanceAppInfo = [[YH_PerformanceAppInfo alloc] init];
self.timer = [NSTimer timerWithTimeInterval:self.timeInterval target:self selector:@selector(timerAction) userInfo:nil repeats:YES];
[[NSRunLoop mainRunLoop] addTimer:self.timer forMode: NSRunLoopCommonModes];
... ... @@ -94,20 +94,6 @@ static NSString *kParamKeyType = @"type";
}
#pragma mark - Getters
-(YH_PerformanceAppInfo *)performanceAppInfo{
if (!_performanceAppInfo) {
_performanceAppInfo = [[YH_PerformanceAppInfo alloc] init];
}
return _performanceAppInfo;
}
//- (NSMutableArray*)eventCacheArray
//{
// if (_eventCacheArray == nil) {
// _eventCacheArray = [[NSMutableArray alloc]initWithCapacity:0];
// }
// return _eventCacheArray;
//}
- (NSMutableArray*)performanceCacheArray
{
... ...