Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can apps provide a hook for Spotlight to search content within the app?

Example: App contains messages. User searches spotlight with string from message. Spotlight finds that app.

I have heard that spotlight can search app contents. But how to feed it to Spotlight on iOS?

like image 516
openfrog Avatar asked Jul 30 '13 13:07

openfrog


People also ask

Is there an app for Spotlight?

Download and install Spotlight Cloud Mobile Click to download for your iPhone and iPad App or Android App.

What is the Spotlight search screen?

Spotlight Search on your Apple® iPad® is used to search for contacts, email, messages, calendars, etc. Swipe down from the middle of the Home Screen. If unavailable, from a Home screen, swipe to the right to access Spotlight Search.

What is the Spotlight app for?

Spotlight can help you quickly find apps, documents, emails, and other items on your Mac. With Siri Suggestions, you can also get news, sports scores, weather conditions, stock prices, and more. Spotlight can even perform calculations and conversions for you.


3 Answers

According to the Core Data Spotlight Integration Programming Guide, the functionality you want is not available for iOS, only for Mac OS X.

like image 195
Jake Spencer Avatar answered Sep 21 '22 06:09

Jake Spencer


This is now possible from iOS9 onwards.

Apple has released a CoreSpotlight SDK (WWDC2015) where, you can integrate your app to the spotlight of iOS and can do a content search.

There are other possible avenues to actually integrate different user activities to your app and can also search for things even when your app is not installed on the device.

If your app is an app that handles pdf for instance, if user searches for a pdf on his device, you app can come up in the spotlight preferences as an app he can use to read the pdf, even when your app is not installed on the user's device.

Considering your example, now its possible that if you search for a message string in spotlight, spotlight can open up your app and you can make the user actually navigate to find the exact message inside your app as well.

Adding link below : You can find details for implementation.

https://developer.apple.com/library/prerelease/ios/releasenotes/General/WhatsNewIniOS/Articles/iOS9.html#//apple_ref/doc/uid/TP40016198-SW3

-Tejas

like image 23
Tejas HS Avatar answered Sep 20 '22 06:09

Tejas HS


Here is an example of adding your app content to Spotlight via the new Search API's. This is available on iOS9 using XCode 7.

CSSearchableItemAttributeSet * attributes = [[CSSearchableItemAttributeSet alloc] initWithItemContentType:(NSString *)kUTTypeImage]; //Or whatever type
attributes.contentDescription = @"This is my content description.";
attributes.displayName = @"Display Name";
attributes.keywords = @["Stuff","Widget"];
attributes.subject = @"Subject";
attributes.title = @"Title";

CSSearchableItem *item = [[CSSearchableItem alloc] initWithUniqueIdentifier:someUniqueId domainIdentifier:@"SomeGroupName" attributeSet:attributes];

[[CSSearchableIndex defaultSearchableIndex] indexSearchableItems:@[item] completionHandler:nil];

When the user selects the item in spotlight, the following method:

-(BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray *))restorationHandler

in your AppDelegate will be called. Check the userInfo dictionary in the userActivity object and send the user to the appropriate screen.

like image 42
reshat2 Avatar answered Sep 19 '22 06:09

reshat2