Skip to content

Commit a10d29e

Browse files
committed
white listed functionality
1 parent be29f4d commit a10d29e

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

Branch-SDK/Branch-SDK/Branch.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,19 @@ typedef NS_ENUM(NSUInteger, BranchCreditHistoryOrder) {
357357
*/
358358
-(void)setDeepLinkDebugMode:(NSDictionary *)debugParams;
359359

360+
/**
361+
Add a scheme to a whitelist of URI schemes that will be tracked by Branch. Default to all schemes.
362+
363+
@param the scheme to add to the whitelist, i.e. @"http", @"https" or @"myapp"
364+
*/
365+
-(void)addWhiteListedScheme:(NSString *)scheme;
366+
367+
/**
368+
Add an array of schemes to a whitelist of URI schemes that will be tracked by Branch. Default to all schemes.
369+
370+
@param the array of schemes to add to the whitelist, i.e. @[@"http", @"https", @"myapp"]
371+
*/
372+
-(void)setWhiteListedSchemes:(NSArray *)schemes;
360373

361374
/**
362375
Register your Facebook SDK's FBSDKAppLinkUtility class to be used by Branch for deferred deep linking from their platform

Branch-SDK/Branch-SDK/Branch.m

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ @interface Branch() <BranchDeepLinkingControllerCompletionDelegate, FABKit>
8080
@property (strong, nonatomic) NSDictionary *deepLinkDebugParams;
8181
@property (assign, nonatomic) BOOL accountForFacebookSDK;
8282
@property (assign, nonatomic) id FBSDKAppLinkUtility;
83+
@property (strong, nonatomic) NSMutableArray *whiteListedSchemes;
8384

8485
@end
8586

@@ -147,6 +148,7 @@ - (id)initWithInterface:(BNCServerInterface *)interface queue:(BNCServerRequestQ
147148
_processing_sema = dispatch_semaphore_create(1);
148149
_networkCount = 0;
149150
_deepLinkControllers = [[NSMutableDictionary alloc] init];
151+
_whiteListedSchemes = [[NSMutableArray alloc] init];
150152
_useCookieBasedMatching = YES;
151153

152154
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
@@ -320,12 +322,28 @@ - (void) setDeepLinkDebugMode:(NSDictionary *)debugParams {
320322
self.deepLinkDebugParams = debugParams;
321323
}
322324

325+
-(void)setWhiteListedSchemes:(NSArray *)schemes {
326+
self.whiteListedSchemes = [schemes mutableCopy];
327+
}
328+
329+
-(void)addWhiteListedScheme:(NSString *)scheme {
330+
[self.whiteListedSchemes addObject:scheme];
331+
}
323332

324333
- (BOOL)handleDeepLink:(NSURL *)url {
325334
BOOL handled = NO;
326335
if (url && ![url isEqual:[NSNull null]]) {
327-
//always save the incoming url in the preferenceHelper in the externalIntentURI field
328-
self.preferenceHelper.externalIntentURI = [url absoluteString];
336+
337+
// save the incoming url in the preferenceHelper in the externalIntentURI field
338+
if ([self.whiteListedSchemes count]) {
339+
for (NSString *scheme in self.whiteListedSchemes) {
340+
if ([scheme isEqualToString:[url scheme]]) {
341+
self.preferenceHelper.externalIntentURI = [url absoluteString];
342+
}
343+
}
344+
} else {
345+
self.preferenceHelper.externalIntentURI = [url absoluteString];
346+
}
329347

330348
NSString *query = [url fragment];
331349
if (!query) {

0 commit comments

Comments
 (0)