From 70b93db760d3e91b09ccc17e774eb1ff3c9e620c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Mon, 7 May 2018 10:48:08 -0700 Subject: [ios] Use China events endpoint with China API endpoint --- platform/darwin/src/MGLNetworkConfiguration.h | 6 ++++++ platform/darwin/src/MGLNetworkConfiguration.m | 3 +++ platform/ios/src/MGLAPIClient.m | 6 +++++- 3 files changed, 14 insertions(+), 1 deletion(-) 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]; } -- cgit v1.2.1