Reputation: 2457
iOS 9.2, xCode 7.2, Objective-C
I used this tutorial (Core Spotlight version) but translated it into Objective-C: http://code.tutsplus.com/tutorials/ios-9-introducing-search-apis--cms-24375
Everything works except one thing - I can't get callback when user taps the search result. It seems I need to write the following method in my app delegate:
- (BOOL)application:(UIApplication *)application
continueUserActivity:(NSUserActivity *)userActivity
restorationHandler:(void (^)(NSArray *restorableObjects))restorationHandler
But it is not called at all. How to solve this issue?
Upvotes: 2
Views: 2666
Reputation: 1010
You have to first check your activity has type search action :
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void(^)(NSArray * __nullable restorableObjects))restorationHandler
{
if ([[userActivity activityType] isEqualToString:CSSearchableItemActionType])
{
NSString *uniqueIdentifier = [userActivity.userInfo objectForKey:CSSearchableItemActivityIdentifier];
NSLog(@"%@",uniqueIdentifier);
// Launch Detail controller
}
return YES;
}
Hope it helps you!!
Upvotes: 6