User-Agent,Device-UUID
1.iOS中有时候和后台协商后可能需要添加 User-Agent,Device-UUID
我们这个时候添加了一个继承 AFHTTPSessionManager 的单列,在这个地方可以添加User-Agent和Device-UUID
- (instancetype)sharedXMNotPolicyClient
{
static BikeNetworkAPIClient _shareClient = nil;
static dispatch_once_t onceToken;//线程安全
dispatch_once(&onceToken, ^{
_shareClient = [[BikeNetworkAPIClient alloc] initWithBaseURL:[NSURL URLWithString:XM_API_SERVERNew]];
_shareClient.securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeNone];
_shareClient.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/xml", @"application/json", @"text/html",@"text/json",@"text/javascript", @"text/plain", nil];
_shareClient.requestSerializer.timeoutInterval = TimeoutInterval;
NSStringuuid=[CMUUIDManager readUUID];
// NSString *strHeader = [NSString stringWithFormat:@"iOS,%@,%@",kVersion,uuid];
//下面有一个空格 千万不能删,空格是一个标识符
NSString *strHeader = [NSString stringWithFormat:@"iOS/%@, com.cronusbike.DingdingTravel/%@",KXMCurrentDeviceSystemVersion,kVersion];
[_shareClient.requestSerializer setValue:strHeader forHTTPHeaderField:@"User-Agent"];
[_shareClient.requestSerializer setValue:uuid forHTTPHeaderField:@"Device-UUID"];
});
return _shareClient;
}