Skip to content

Commit 9db403b

Browse files
committed
indexing cleanup
1 parent 95b3093 commit 9db403b

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

Branch-SDK/Branch-SDK/BNCContentDiscoveryManager.m

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -416,18 +416,14 @@ - (void)indexContentWithTitle:(NSString *)title
416416

417417

418418
- (void)indexContentWithUrl:(NSString *)url spotlightIdentifier:(NSString *)spotlightIdentifier title:(NSString *)title description:(NSString *)description type:(NSString *)type thumbnailUrl:(NSURL *)thumbnailUrl thumbnailData:(NSData *)thumbnailData publiclyIndexable:(BOOL)publiclyIndexable userInfo:(NSDictionary *)userInfo keywords:(NSSet *)keywords expirationDate:(NSDate *)expirationDate callback:(callbackWithUrl)callback spotlightCallback:(callbackWithUrlAndSpotlightIdentifier)spotlightCallback {
419-
// NSUserActivity is available iOS 8+
420-
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000
419+
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 90000
421420

422421
id CSSearchableItemAttributeSetClass = NSClassFromString(@"CSSearchableItemAttributeSet");
423422
id attributes = [CSSearchableItemAttributeSetClass alloc];
424423
SEL initAttributesSelector = NSSelectorFromString(@"initWithItemContentType:");
425424
attributes = ((id (*)(id, SEL, NSString *))[attributes methodForSelector:initAttributesSelector])(attributes, initAttributesSelector, type);
426425
SEL setIdentifierSelector = NSSelectorFromString(@"setIdentifier:");
427426
((void (*)(id, SEL, NSString *))[attributes methodForSelector:setIdentifierSelector])(attributes, setIdentifierSelector, spotlightIdentifier);
428-
// NSUserActivity.CSSearchableItemAttributeSet.relatedUniqueIdentifier
429-
SEL setRelatedUniqueIdentifierSelector = NSSelectorFromString(@"setRelatedUniqueIdentifier:");
430-
((void (*)(id, SEL, NSString *))[attributes methodForSelector:setRelatedUniqueIdentifierSelector])(attributes, setRelatedUniqueIdentifierSelector, url);
431427
SEL setTitleSelector = NSSelectorFromString(@"setTitle:");
432428
((void (*)(id, SEL, NSString *))[attributes methodForSelector:setTitleSelector])(attributes, setTitleSelector, title);
433429
SEL setContentDescriptionSelector = NSSelectorFromString(@"setContentDescription:");
@@ -449,6 +445,15 @@ - (void)indexContentWithUrl:(NSString *)url spotlightIdentifier:(NSString *)spot
449445
@"attributeSet": attributes
450446
};
451447
[self indexUsingNSUserActivity:userActivityIndexingParams];
448+
449+
// not handling error scenarios because they are already handled upstream by the caller
450+
if (url) {
451+
if (callback) {
452+
callback(url, nil);
453+
} else if (spotlightCallback) {
454+
spotlightCallback(url, spotlightIdentifier, nil);
455+
}
456+
}
452457
#endif
453458
}
454459

@@ -478,20 +483,19 @@ - (UIViewController *)getActiveViewController:(UIViewController *)rootViewContro
478483
}
479484

480485
- (void)indexUsingNSUserActivity:(NSDictionary *)params {
481-
NSLog(@"indexUsingNSUserActivity %@", params);
482486
self.userInfo = params[@"userInfo"];
483487
self.userInfo[CSSearchableItemActivityIdentifier] = params[@"spotlightId"];
484488

485489
UIViewController *activeViewController = [self getActiveViewController];
486490
NSString *uniqueIdentifier = [NSString stringWithFormat:@"io.branch.%@", [[NSBundle mainBundle] bundleIdentifier]];
487491
activeViewController.userActivity = [[NSUserActivity alloc] initWithActivityType:uniqueIdentifier];
492+
activeViewController.userActivity.delegate = self;
488493
activeViewController.userActivity.title = params[@"title"];
489494
activeViewController.userActivity.webpageURL = [NSURL URLWithString:params[@"url"]];
490495
activeViewController.userActivity.eligibleForSearch = YES;
491496
activeViewController.userActivity.eligibleForPublicIndexing = params[@"publiclyIndexable"];
492-
activeViewController.userActivity.userInfo = self.userInfo;
493-
activeViewController.userActivity.delegate = self;
494-
activeViewController.userActivity.requiredUserInfoKeys = [NSSet setWithArray:self.userInfo.allKeys]; // This, however, seems to force the userInfo to come through.
497+
activeViewController.userActivity.userInfo = self.userInfo; // This alone doesn't pass userInfo thru
498+
activeViewController.userActivity.requiredUserInfoKeys = [NSSet setWithArray:self.userInfo.allKeys]; // This along with the delegate method userActivityWillSave, however, seem to force the userInfo to come through.
495499
activeViewController.userActivity.keywords = params[@"keywords"];
496500
SEL setContentAttributeSetSelector = NSSelectorFromString(@"setContentAttributeSet:");
497501
((void (*)(id, SEL, id))[activeViewController.userActivity methodForSelector:setContentAttributeSetSelector])(activeViewController.userActivity, setContentAttributeSetSelector, params[@"attributeSet"]);

Branch-SDK/Branch-SDK/BranchUniversalObject.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ typedef NS_ENUM(NSInteger, ContentIndexMode) {
6060

6161
- (void)listOnSpotlight;
6262
- (void)listOnSpotlightWithCallback:(callbackWithUrl)callback;
63-
// DEPRECATE https://dev.branch.io/features/spotlight-indexing/overview/
64-
//Message: “iOS 10 has changed how Spotlight indexing works and we’ve updated the SDK to reflect this. Please see <link> for instructions on migration"
65-
- (void)listOnSpotlightWithIdentifierCallback:(callbackWithUrlAndSpotlightIdentifier)spotlightCallback;
63+
- (void)listOnSpotlightWithIdentifierCallback:(callbackWithUrlAndSpotlightIdentifier)spotlightCallback __attribute__((deprecated(("iOS 10 has changed how Spotlight indexing works and we’ve updated the SDK to reflect this. Please see https://dev.branch.io/features/spotlight-indexing/overview/ for instructions on migration"))));;
6664

6765
// Convenience method for initSession methods that return BranchUniversalObject, but can be used safely by anyone.
6866
+ (BranchUniversalObject *)getBranchUniversalObjectFromDictionary:(NSDictionary *)dictionary;

0 commit comments

Comments
 (0)