Skip to content

Commit 62031f9

Browse files
committed
minor refactor
1 parent 9db403b commit 62031f9

File tree

4 files changed

+12
-21
lines changed

4 files changed

+12
-21
lines changed

Branch-SDK/Branch-SDK/BNCContentDiscoveryManager.m

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,15 @@ @implementation BNCContentDiscoveryManager
3939
#pragma mark - Launch handling
4040

4141
- (NSString *)spotlightIdentifierFromActivity:(NSUserActivity *)userActivity {
42-
4342
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000
44-
// Matched if it has our prefix, then the link identifier is just the last piece of the identifier.
43+
// If it has our prefix, then the link identifier is just the last piece of the identifier.
4544
NSString *activityIdentifier = userActivity.userInfo[CSSearchableItemActivityIdentifier];
4645
BOOL isBranchIdentifier = [activityIdentifier hasPrefix:BRANCH_SPOTLIGHT_PREFIX];
4746

47+
// Checking for CSSearchableItemActionType in the activity for legacy spotlight indexing (pre 0.12.7)
48+
// Now we index NSUserActivies with type set to io.branch. + bundleId for better SEO
4849
if ([userActivity.activityType isEqualToString:CSSearchableItemActionType] || isBranchIdentifier) {
49-
return activityIdentifier;
50+
return activityIdentifier;
5051
}
5152
#endif
5253

@@ -446,7 +447,7 @@ - (void)indexContentWithUrl:(NSString *)url spotlightIdentifier:(NSString *)spot
446447
};
447448
[self indexUsingNSUserActivity:userActivityIndexingParams];
448449

449-
// not handling error scenarios because they are already handled upstream by the caller
450+
// Not handling error scenarios because they are already handled upstream by the caller
450451
if (url) {
451452
if (callback) {
452453
callback(url, nil);
@@ -488,13 +489,14 @@ - (void)indexUsingNSUserActivity:(NSDictionary *)params {
488489

489490
UIViewController *activeViewController = [self getActiveViewController];
490491
NSString *uniqueIdentifier = [NSString stringWithFormat:@"io.branch.%@", [[NSBundle mainBundle] bundleIdentifier]];
492+
// Can't create any weak references here to the userActivity, otherwise it will not index.
491493
activeViewController.userActivity = [[NSUserActivity alloc] initWithActivityType:uniqueIdentifier];
492494
activeViewController.userActivity.delegate = self;
493495
activeViewController.userActivity.title = params[@"title"];
494496
activeViewController.userActivity.webpageURL = [NSURL URLWithString:params[@"url"]];
495497
activeViewController.userActivity.eligibleForSearch = YES;
496498
activeViewController.userActivity.eligibleForPublicIndexing = params[@"publiclyIndexable"];
497-
activeViewController.userActivity.userInfo = self.userInfo; // This alone doesn't pass userInfo thru
499+
activeViewController.userActivity.userInfo = self.userInfo; // This alone doesn't pass userInfo through
498500
activeViewController.userActivity.requiredUserInfoKeys = [NSSet setWithArray:self.userInfo.allKeys]; // This along with the delegate method userActivityWillSave, however, seem to force the userInfo to come through.
499501
activeViewController.userActivity.keywords = params[@"keywords"];
500502
SEL setContentAttributeSetSelector = NSSelectorFromString(@"setContentAttributeSet:");

Branch-SDK/Branch-SDK/Branch.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ - (BOOL)continueUserActivity:(NSUserActivity *)userActivity {
406406
return NO;
407407
}
408408

409-
//check to see if a spotlight activity needs to be handled
409+
// Check to see if a spotlight activity needs to be handled
410410
NSString *spotlightIdentifier = [self.contentDiscoveryManager spotlightIdentifierFromActivity:userActivity];
411411

412412
if (spotlightIdentifier) {
@@ -418,6 +418,7 @@ - (BOOL)continueUserActivity:(NSUserActivity *)userActivity {
418418
self.preferenceHelper.spotlightIdentifier = nonBranchSpotlightIdentifier;
419419
}
420420
}
421+
421422
[self initUserSessionAndCallCallback:YES];
422423
self.preferenceHelper.shouldWaitForInit = NO;
423424

@@ -1325,4 +1326,4 @@ + (NSString *)kitDisplayVersion {
13251326
return @"0.12.6";
13261327
}
13271328

1328-
@end
1329+
@end

Branch-TestBed/Branch-TestBed/AppDelegate.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
2020
*/
2121

2222
Branch *branch = [Branch getInstance];
23-
[branch setDebug];
23+
//[branch setDebug];
2424
[branch setWhiteListedSchemes:@[@"branchtest"]];
2525

2626
// Automatic Deeplinking on "deeplink_text"
@@ -69,7 +69,7 @@ - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceAppl
6969

7070

7171
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray *))restorationHandler {
72-
NSLog(@"application:continueUserActivity:restorationHandler: invoked. userActivity.webpageURL if any: %@", userActivity.webpageURL.absoluteString);
72+
NSLog(@"application:continueUserActivity:restorationHandler: invoked. activityType: %@ userActivity.webpageURL: %@", userActivity.activityType, userActivity.webpageURL.absoluteString);
7373

7474
// Required. Returns YES if Branch Universal Link, else returns NO. Add `branch_universal_link_domains` to .plist (String or Array) for custom domain(s).
7575
[[Branch getInstance] continueUserActivity:userActivity];

Branch-TestBed/Branch-TestBed/ViewController.m

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -198,18 +198,6 @@ - (IBAction)shareLinkButtonTouchUpInside:(id)sender {
198198
}
199199

200200

201-
/*
202-
- (IBAction)cmdIndexSpotlight:(id)sender {
203-
[self.branchUniversalObject listOnSpotlightWithCallback:^(NSString *url, NSError *error) {
204-
if (!error) {
205-
NSLog(@"Branch TestBed: ShortURL: %@", url);
206-
} else {
207-
NSLog(@"Branch TestBed: Error: %@", error);
208-
}
209-
}];
210-
}*/
211-
212-
213201
//example using callbackWithURLandSpotlightIdentifier
214202
- (IBAction)registerWithSpotlightButtonTouchUpInside:(id)sender {
215203
[self.branchUniversalObject addMetadataKey:@"deeplink_text" value:@"This link was generated for Spotlight registration"];

0 commit comments

Comments
 (0)