File tree Expand file tree Collapse file tree 6 files changed +25
-7
lines changed
Branch-TestBed/Branch-TestBed Expand file tree Collapse file tree 6 files changed +25
-7
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,10 @@ - (BOOL)application:(UIApplication *)application
3434
3535 // Branch.useTestBranchKey = YES; // Make sure to comment this line out for production apps!!!
3636 Branch *branch = [Branch getInstance ];
37-
37+
38+ // Change the Branch base API URL
39+ // [branch setAPIUrl:@"https://api3.branch.io"];
40+
3841 // test pre init support
3942 // [self testDispatchToIsolationQueue:branch]
4043
Original file line number Diff line number Diff line change 2626static NSString * const BRANCH_PREFS_KEY_LAST_RUN_BRANCH_KEY = @" bnc_last_run_branch_key" ;
2727static NSString * const BRANCH_PREFS_KEY_LAST_STRONG_MATCH_DATE = @" bnc_strong_match_created_date" ;
2828
29- static NSString * const BRANCH_PREFS_KEY_API_URL = @" bnc_api_url " ;
29+ static NSString * const BRANCH_PREFS_KEY_CUSTOM_API_URL = @" bnc_custom_api_url " ;
3030static NSString * const BRANCH_PREFS_KEY_PATTERN_LIST_URL = @" bnc_pattern_list_url" ;
3131
3232static NSString * const BRANCH_PREFS_KEY_RANDOMIZED_DEVICE_TOKEN = @" bnc_randomized_device_token" ;
@@ -160,24 +160,23 @@ - (void)setBranchAPIURL:(NSString *)url {
160160 if ([url hasPrefix: @" http://" ] || [url hasPrefix: @" https://" ] ){
161161 @synchronized (self) {
162162 _branchAPIURL = [url copy ];
163- [self writeObjectToDefaults: BRANCH_PREFS_KEY_API_URL value: _branchAPIURL];
163+ [self writeObjectToDefaults: BRANCH_PREFS_KEY_CUSTOM_API_URL value: _branchAPIURL];
164164 }
165165 } else {
166166 BNCLogWarning (@" Ignoring invalid custom API URL" );
167167 }
168168}
169169
170- // TODO: This method is not used with the Tracking domain change. See SDK-2118
171170- (NSString *)branchAPIURL {
172171 @synchronized (self) {
173172 if (!_branchAPIURL) {
174- _branchAPIURL = [self readStringFromDefaults: BRANCH_PREFS_KEY_API_URL ];
173+ _branchAPIURL = [self readStringFromDefaults: BRANCH_PREFS_KEY_CUSTOM_API_URL ];
175174 }
176175
177176 // return the default URL in the event there's nothing in storage
178177 if (_branchAPIURL == nil || [_branchAPIURL isEqualToString: @" " ]) {
179178 _branchAPIURL = [BNC_API_URL copy ];
180- [self writeObjectToDefaults: BRANCH_PREFS_KEY_API_URL value: _branchAPIURL];
179+ [self writeObjectToDefaults: BRANCH_PREFS_KEY_CUSTOM_API_URL value: _branchAPIURL];
181180 }
182181
183182 return _branchAPIURL;
Original file line number Diff line number Diff line change 99#import " BNCSystemObserver.h"
1010#import " BNCConfig.h"
1111#import " BranchConstants.h"
12+ #import " BNCPreferenceHelper.h"
1213
1314@implementation BNCServerAPI
1415
@@ -88,6 +89,12 @@ - (NSString *)getBaseURLForLinkingEndpoints {
8889}
8990
9091- (NSString *)getBaseURL {
92+ // Check if user has set a custom API base URL
93+ NSString *url = [[BNCPreferenceHelper sharedInstance ] branchAPIURL ];
94+ if (url && ![url isEqualToString: BNC_API_URL]) {
95+ return url;
96+ }
97+
9198 if (self.automaticallyEnableTrackingDomain ) {
9299 self.useTrackingDomain = [self optedIntoIDFA ];
93100 }
Original file line number Diff line number Diff line change @@ -575,6 +575,12 @@ extern NSString * __nonnull const BNCSpotlightFeature;
575575 */
576576- (void )useEUEndpoints ;
577577
578+ /* *
579+ Sets a custom base URL for all calls to the Branch API.
580+ @param url Base URL that the Branch API will use.
581+ */
582+ - (void )setAPIUrl : (NSString *)url ;
583+
578584/* *
579585 setDebug is deprecated and all functionality has been disabled.
580586
Original file line number Diff line number Diff line change @@ -426,6 +426,10 @@ - (void)useEUEndpoints {
426426 [BNCServerAPI sharedInstance ].useEUServers = YES ;
427427}
428428
429+ - (void )setAPIUrl : (NSString *)url {
430+ [[BNCPreferenceHelper sharedInstance ] setBranchAPIURL: url];
431+ }
432+
429433- (void )setDebug {
430434 NSLog (@" Branch setDebug is deprecated and all functionality has been disabled. "
431435 " If you wish to enable logging, please invoke enableLogging. "
Original file line number Diff line number Diff line change @@ -54,7 +54,6 @@ + (BranchPluginSupport *)instance {
5454
5555#pragma mark - Server URL methods
5656
57- // With the change to support Apple's tracking domain feature, this API no longer works. See SDK-2118
5857// Overrides base API URL
5958+ (void )setAPIUrl : (NSString *)url {
6059 [[BNCPreferenceHelper sharedInstance ] setBranchAPIURL: url];
You can’t perform that action at this time.
0 commit comments