diff --git a/BranchSDK/Branch.h b/BranchSDK/Branch.h index 2f42f99d2..1ef83a061 100644 --- a/BranchSDK/Branch.h +++ b/BranchSDK/Branch.h @@ -576,6 +576,12 @@ extern NSString * __nonnull const BNCSpotlightFeature; */ - (void)useEUEndpoints; +/** +Sets a custom base URL for all calls to the Branch API. +@param url Base URL that the Branch API will use. +*/ ++ (void)setAPIUrl:(NSString *)url; + /** @brief Use the `validateSDKIntegration` method as a debugging aid to assure that you've integrated the Branch SDK correctly. diff --git a/BranchSDK/Branch.m b/BranchSDK/Branch.m index e4068e78c..d91fb6d8f 100644 --- a/BranchSDK/Branch.m +++ b/BranchSDK/Branch.m @@ -434,6 +434,14 @@ - (void)useEUEndpoints { [BNCServerAPI sharedInstance].useEUServers = YES; } ++ (void)setAPIUrl:(NSString *)url { + if ([url hasPrefix:@"http://"] || [url hasPrefix:@"https://"] ){ + [BNCServerAPI sharedInstance].customAPIURL = url; + } else { + [[BranchLogger shared] logWarning:(@"Ignoring invalid custom API URL")]; + } +} + - (void)validateSDKIntegration { [self validateSDKIntegrationCore]; }