blob: 3c58dfb7d1df803ab985640355339bd2d8f9a8a7 (
plain)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
#import <Foundation/Foundation.h>
#import <mbgl/interface/native_apple_interface.h>
@implementation MGLNativeNetworkManager
static MGLNativeNetworkManager *instance = nil;
+ (MGLNativeNetworkManager *)sharedManager {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
instance = [[MGLNativeNetworkManager alloc] init];
});
return instance;
}
+ (NSURLSessionConfiguration *)testSessionConfiguration {
NSURLSessionConfiguration* sessionConfiguration = [NSURLSessionConfiguration defaultSessionConfiguration];
sessionConfiguration.timeoutIntervalForResource = 30;
sessionConfiguration.HTTPMaximumConnectionsPerHost = 8;
sessionConfiguration.requestCachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
sessionConfiguration.URLCache = nil;
return sessionConfiguration;
}
#pragma mark - Optionals
- (NSString *)skuToken {
if([self.delegate respondsToSelector:@selector(skuToken)]) {
return [self.delegate skuToken];
}
return nil;
}
#pragma mark - Required
- (NSURLSessionConfiguration *)sessionConfiguration {
NSURLSessionConfiguration *configuration = [_delegate sessionConfiguration];
if (!configuration) {
// For testing. Since we get a `nil` return when SDK is modular, we use
// this for testing requests.
// Same as `[MGLNetworkConfiguration defaultSessionConfiguration]` in
// `MGLNetworkConfiguration.m`.
configuration = [MGLNativeNetworkManager testSessionConfiguration];
}
return configuration;
}
- (void)startDownloadEvent:(NSString *)event type:(NSString *)type {
[self.delegate startDownloadEvent:event type:type];
}
- (void)cancelDownloadEventForResponse:(NSURLResponse *)response {
[self.delegate cancelDownloadEventForResponse:response];
}
- (void)stopDownloadEventForResponse:(NSURLResponse *)response {
[self.delegate stopDownloadEventForResponse:response];
}
- (void)debugLog:(NSString *)format, ... {
// TODO: Replace with existing mbgl logging handling.
[self.delegate debugLog:format];
}
- (void)errorLog:(NSString *)format, ... {
// TODO: Replace with existing mbgl logging handling.
[self.delegate errorLog:format];
}
@end
|