diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2018-05-07 10:48:08 -0700 |
---|---|---|
committer | Minh Nguyễn <mxn@1ec5.org> | 2018-05-07 10:48:08 -0700 |
commit | 70b93db760d3e91b09ccc17e774eb1ff3c9e620c (patch) | |
tree | 72083e7c62f01ee74376fa5e2e75f854fee7d395 | |
parent | ff4c5e12e1f17f216bb405eb18c6dc6ece8f556e (diff) | |
download | qtlocation-mapboxgl-upstream/1ec5-events-cn-11845.tar.gz |
[ios] Use China events endpoint with China API endpointupstream/1ec5-events-cn-11845
-rw-r--r-- | platform/darwin/src/MGLNetworkConfiguration.h | 6 | ||||
-rw-r--r-- | platform/darwin/src/MGLNetworkConfiguration.m | 3 | ||||
-rw-r--r-- | platform/ios/src/MGLAPIClient.m | 6 |
3 files changed, 14 insertions, 1 deletions
diff --git a/platform/darwin/src/MGLNetworkConfiguration.h b/platform/darwin/src/MGLNetworkConfiguration.h index 644291ee13..f1fe7bab2c 100644 --- a/platform/darwin/src/MGLNetworkConfiguration.h +++ b/platform/darwin/src/MGLNetworkConfiguration.h @@ -2,6 +2,12 @@ NS_ASSUME_NONNULL_BEGIN +/// The default base URL for Mapbox APIs other than the telemetry API. +extern NSString * const MGLDefaultMapboxAPIBaseURL; + +/// The PRC base URL for Mapbox APIs other than the telemetry API. +extern NSString * const MGLChinaMapboxAPIBaseURL; + /** The MGLNetworkConfiguration object provides a global way to set a base API URL for retrieval of map data, styles, and other resources. diff --git a/platform/darwin/src/MGLNetworkConfiguration.m b/platform/darwin/src/MGLNetworkConfiguration.m index 82d333dc99..d0ee01c5a2 100644 --- a/platform/darwin/src/MGLNetworkConfiguration.m +++ b/platform/darwin/src/MGLNetworkConfiguration.m @@ -1,5 +1,8 @@ #import "MGLNetworkConfiguration.h" +NSString * const MGLDefaultMapboxAPIBaseURL = @"https://api.mapbox.com"; +NSString * const MGLChinaMapboxAPIBaseURL = @"https://api.mapbox.cn"; + @implementation MGLNetworkConfiguration + (void)load { diff --git a/platform/ios/src/MGLAPIClient.m b/platform/ios/src/MGLAPIClient.m index e29b419c07..49e234db94 100644 --- a/platform/ios/src/MGLAPIClient.m +++ b/platform/ios/src/MGLAPIClient.m @@ -2,9 +2,11 @@ #import "NSBundle+MGLAdditions.h" #import "NSData+MGLAdditions.h" #import "MGLAccountManager.h" +#import "MGLNetworkConfiguration.h" static NSString * const MGLAPIClientUserAgentBase = @"MapboxEventsiOS"; -static NSString * const MGLAPIClientBaseURL = @"https://events.mapbox.cn"; +static NSString * const MGLAPIClientBaseURL = @"https://events.mapbox.com"; +static NSString * const MGLAPIClientChinaBaseURL = @"https://events.mapbox.cn"; static NSString * const MGLAPIClientEventsPath = @"events/v2"; static NSString * const MGLAPIClientHeaderFieldUserAgentKey = @"User-Agent"; @@ -104,6 +106,8 @@ static NSString * const MGLAPIClientHTTPMethodPost = @"POST"; if (testServerURL && [testServerURL.scheme isEqualToString:@"https"]) { self.baseURL = testServerURL; self.usesTestServer = YES; + } else if ([[[NSBundle mainBundle] objectForInfoDictionaryKey:@"MGLMapboxAPIBaseURL"] isEqualToString:MGLChinaMapboxAPIBaseURL]) { + self.baseURL = [NSURL URLWithString:MGLAPIClientChinaBaseURL]; } else { self.baseURL = [NSURL URLWithString:MGLAPIClientBaseURL]; } |