...
|
...
|
@@ -33,7 +33,7 @@ |
|
|
{
|
|
|
self = [super init];
|
|
|
if (self) {
|
|
|
self.httpClient = [[AFHTTPRequestOperationManager alloc] initWithBaseURL:[NSURL URLWithString:kURLAnalyticsService]];
|
|
|
self.httpClient = [AFHTTPRequestOperationManager manager];
|
|
|
self.httpClient.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/plain"];
|
|
|
self.httpClient.securityPolicy.allowInvalidCertificates = YES;
|
|
|
self.httpClient.operationQueue.maxConcurrentOperationCount = 6;
|
...
|
...
|
@@ -77,8 +77,38 @@ |
|
|
|
|
|
NSString *parsJsonStr = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
|
|
NSDictionary *newParameters = @{@"_mlogs": kSafeValue(parsJsonStr)};
|
|
|
|
|
|
return [self.httpClient POST:kURLAnalyticsService priority:NSOperationQueuePriorityLow parameters:newParameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
|
|
|
|
|
|
if (block) {
|
|
|
block(YES, nil);
|
|
|
}
|
|
|
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
|
|
|
if (block) {
|
|
|
block(NO, error);
|
|
|
}
|
|
|
}];
|
|
|
}
|
|
|
|
|
|
- (AFHTTPRequestOperation *)uploadLogcustomURL:(NSString *)url parameters:(NSDictionary *)parameters completionBlock:(void (^)(BOOL success, NSError *error))block
|
|
|
{
|
|
|
NSError *error = nil;
|
|
|
NSMutableDictionary *actualParameters = [NSMutableDictionary dictionaryWithDictionary:parameters];
|
|
|
|
|
|
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:actualParameters options:0 error:&error];
|
|
|
if (error) {
|
|
|
YALog(@"json parsing, connot convert to json for: %@\n code: %ld\n reason: %@", actualParameters, (long)[error code], [error localizedDescription]);
|
|
|
|
|
|
if (block) {
|
|
|
block(NO, error);
|
|
|
}
|
|
|
return nil;
|
|
|
}
|
|
|
|
|
|
return [self.httpClient POST:kYASApiMethodUploadData priority:NSOperationQueuePriorityLow parameters:newParameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
|
|
|
NSString *parsJsonStr = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
|
|
NSDictionary *newParameters = @{@"_mlogs": kSafeValue(parsJsonStr)};
|
|
|
|
|
|
return [self.httpClient POST:url priority:NSOperationQueuePriorityLow parameters:newParameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
|
|
|
|
|
|
if (block) {
|
|
|
block(YES, nil);
|
...
|
...
|
|