YH_HTTPRequestSerializer.m
1.62 KB
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
//
// YH_HttpRequestSerializer.m
// YH_Mall
//
// Created by jhsonzhi on 15/8/24.
// Copyright (c) 2015年 YOHO. All rights reserved.
//
#import "YH_HttpRequestSerializer.h"
#import <OpenUDID.h>
#import <JTSHardwareInfo.h>
#import "UtilsMacros.h"
#import <YH_Analytics.h>
#import <AdSupport/AdSupport.h>
#define kScreenScale ([UIScreen instancesRespondToSelector:@selector(scale)]?[[UIScreen mainScreen] scale]:(1.0f))
@implementation YH_HttpRequestSerializer
-(instancetype)init
{
if (self = [super init]) {
[self setValue:[self yh_getYohoUserAgent] forHTTPHeaderField:@"User-Agent"];
}
return self;
}
- (NSString *)yh_getYohoUserAgent
{
NSString * udidString = [OpenUDID value];
if (!udidString) {
udidString = @"";
}
NSTimeInterval time = [[NSDate date] timeIntervalSince1970];
long longTime = (long)time;
NSString *userAgent = [NSString stringWithFormat:@"%@/%@(Model/%@;OS/iOS%@;Scale/%0.2f;Channel/%@;Resolution/%ld*%ld;Udid/%@;sid/%@;ts/%ld;uid/%@;ifa/%@)",
[[[NSBundle mainBundle] infoDictionary] objectForKey:(__bridge NSString *)kCFBundleNameKey],
[[[NSBundle mainBundle] infoDictionary] objectForKey:(__bridge NSString *)kCFBundleVersionKey],
[JTSHardwareInfo hardwareDisplayName],[[UIDevice currentDevice] systemVersion],kScreenScale, @"2919",(long)kScreenWidth,(long)kScreenHeight, udidString,[[YH_Analytics sharedInstance] session],longTime, @"",[[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString]];
return userAgent;
}
@end