CoreSpotlight Namespace
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Allows applications to add data to the system search index.
CSCustom |
A key that app developers can associate with metadata for an indexable item that can appear in user search results. |
CSIndex |
Extension methods for the CoreSpotlight.CSIndexErrorCode enumeration. |
CSIndex |
Handler for communication between the application and the index on the device. The app does not need to be running for this communication to occur. |
CSLocalized |
Represents a string-like object that returns a locale-specific version of a string. |
CSMailbox |
Represents keys that identify commonly used mailboxes. |
CSPerson |
An author or a recipient stored in a CSSearchableItemAttributeSet. |
CSSearchable |
A search index used by Spotlight. |
CSSearchable |
Extension methods for T:CoreServices.CSSearchableIndex. |
CSSearchable |
Delegate object providing members that are called when reindexing the index. |
CSSearchable |
Extension methods to the ICSSearchableIndexDelegate interface to support all the methods from the CSSearchableIndexDelegate protocol. |
CSSearchable |
A uniquely identifiable, searchable object in a CSSearchableIndex. |
CSSearchable |
Holds the actual content to be indexed for search. |
CSSearch |
Searches data that the developer has previously indexed with the Core Spotlight API. |
CSSearch |
Extension methods for the CoreSpotlight.CSSearchQueryErrorCode enumeration. |
ICSSearchable |
Interface representing the required methods (if any) of the protocol CSSearchableIndexDelegate. |
CSFile |
Enumerates file protection options in calls to M:CoreSpotlight.CSSearchableIndex.FromName*. |
CSIndex |
Enumerates possible errors associated with using Core Spotlight and searching. |
CSSearch |
Enumerates errors that can occur while running a Core Spotlight query with Start(). |
CSSearchable |
Completion handler used in FetchLastClientState(CSSearchableIndex, CSSearchableIndexFetchHandler). |
Spotlight is the system search technology on iOS and OS X. CoreSpotlight allows developers to add data to the search index. An app about the periodic table, for instance, could index the various elements and bring up the relevant page after a search.
Adding data to Spotlight is done by adding CSSearchableItem objects to the DefaultSearchableIndex:
//Create CSSearchableItems
var dataItems = searchIndexMap.Select (keyValuePair => {
Guid guid = keyValuePair.Key;
String data = keyValuePair.Value;
var attributeSet = new CSSearchableItemAttributeSet (UTType.Text);
attributeSet.Title = data + " Page";
attributeSet.ContentDescription = "My app's data relating to " + data;
attributeSet.TextContent = data;
var dataItem = new CSSearchableItem (guid.ToString (), "com.xamarin.CoreSpotlight0", attributeSet);
return dataItem;
});
//Add items to system index
CSSearchableIndex.DefaultSearchableIndex.Index (dataItems.ToArray<CSSearchableItem> (), err => {
if (err != null) {
Console.WriteLine (err);
} else {
Console.WriteLine ("Indexed items successfully");
}
});
When the application is launched via a Spotlight search for content, the system calls the ContinueUserActivity method with the ActivityType set to ActionType:
public override bool ContinueUserActivity (UIApplication application, NSUserActivity userActivity, UIApplicationRestorationHandler completionHandler)
{
if (userActivity.ActivityType == CSSearchableItem.ActionType) {
var uuid = userActivity.UserInfo.ObjectForKey (CSSearchableItem.ActivityIdentifier);
//... handle Spotlight search for identifier