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

Example: an application contains messages. The user is looking for a spotlight with a string from the message. Spotlight finds that application.

I heard that a spotlight can search the contents of an application. But how to submit it to Spotlight on iOS?

+7
ios iphone ipad spotlight
source share
4 answers

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

+8
source share

Now it is possible with iOS9 and beyond.

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

There are other possibilities for integrating various user actions with your application, as well as searching for things, even if your application is not installed on the device.

If your application is an application that processes pdf, for example, if a user searches for a pdf file on his device, the application may appear in the searchlight settings as an application that he can use to read a pdf file, even if your application is not installed on the user device .

Given your example, it is now possible that if you are looking for a message line in the spotlight, spotlight can open your application, and you can force the user to actually find the exact message inside your application.

Adding a 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

+4
source share

The following is an example of adding your application to Spotlight through the new search APIs. It 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 an item in the spotlight, the following method:

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

in your AppDelegate app. Check the userInfo dictionary in the userActivity object and send it to the appropriate screen.

+1
source share

I created a sample project for integrating corespotlgiht. It works on iOS 9 and requires the creation of Xcode 7 beta 2. You can try if this helps. https://github.com/majain/iPhoneCoreDataRecipes

Link to the video for the same: https://youtu.be/Renm1xLDIFc

+1
source share

All Articles