Skip to content
Titanium SDK
Version13.4.1

Titanium.App.iOS.SearchableIndex

proxyiPhoneiPadmacOSsince 5.0.0

Extends Titanium.Proxy

The SearchableIndex module is used to add or remove Ti.App.iOS.SearchableItem objects from the device search index.

To effectively add and remove information from the iOS search index you will need to use the following modules:

To use this feature make sure you have a compatible device running iOS 9 or later.

Examples

Add Searchable Content to the On-Device Index

The following example demonstrates how to create a new Ti.App.iOS.SearchableItem and add a Ti.App.iOS.SearchableItemAttributeSet. The Ti.App.iOS.SearchableItem is then passed to the Ti.App.iOS.SearchableIndex object to add it to the on-device search index.

app.js

var searchItems = [];
var itemAttr = Ti.App.iOS.createSearchableItemAttributeSet({
    itemContentType: Ti.App.iOS.UTTYPE_IMAGE,
    title:"Titanium Core Spotlight Tutorial",
    contentDescription:"Tech Example \nOn: " + String.formatDate(new Date(),"short"),
    keywords:["Mobile","Appcelerator","Titanium"]
});

var item = Ti.App.iOS.createSearchableItem({
    identifier:"my-id",
    domainIdentifier:"com.mydomain",
    attributeSet:itemAttr
});
searchItems.push(item);

var indexer = Ti.App.iOS.createSearchableIndex();

indexer.addToDefaultSearchableIndex([searchItems],function(e){
    if(e.success){
        alert("Press the home button and now search for your keywords");
    }else{
        alert("Errored: " + JSON.stringify(e.error));
    }
});

Properties 2

apiName

Stringsince Android 3.2.0, iPhone 3.2.0, iPad 3.2.0, macOS 9.2.0read-only

Inherited from Titanium.Proxy

The name of the API that this proxy corresponds to.

bubbleParent

Booleansince Android 3.0.0, iPhone 3.0.0, iPad 3.0.0, macOS 9.2.0

Inherited from Titanium.Proxy

Indicates if the proxy will bubble an event to its parent.

Default: true

Methods 9

Inherited from Titanium.Proxy

Adds the specified callback as an event listener for the named event.

Parameters
ParametersTypeDescription
nameString

Name of the event.

callbackCallback<Titanium.Event>

Callback function to invoke when the event is fired.

4 fields
bubbles Boolean

True if the event will try to bubble up if possible.

cancelBubble Boolean

Set to true to stop the event from bubbling.

source Object

Source object that fired the event.

type String

Name of the event fired.

Adds an array of Titanium.App.iOS.SearchableItem objects to the default search index.

Parameters
ParametersTypeDescription
ArrayArray<Titanium.App.iOS.SearchableItem>

Array of Titanium.App.iOS.SearchableItem objects to be added to the default search index.

callbackCallback<Dictionary>

Function to invoke on success or failure of adding the array Titanium.App.iOS.SearchableItem object to the default search index.

Removes search items based on an array of domain identifiers.

Parameters
ParametersTypeDescription
ArrayArray<String>

Array of domain identifiers to be removed from the default search index.

callbackCallback<Dictionary>

Function to invoke on success or failure of removing search items from the default search index.

Removes all search items added by the application.

Parameters
ParametersTypeDescription
callbackCallback<Dictionary>

Function to invoke on success or failure of deleting all search items.

Removes search items based on an array of identifiers.

Parameters
ParametersTypeDescription
ArrayArray<String>

Array of identifiers to be removed from the default search index.

callbackCallback<Dictionary>

Function to invoke on success or failure of removing search items from the default search index.

Inherited from Titanium.Proxy

Fires a synthesized event to any registered listeners.

Parameters
ParametersTypeDescription
nameString

Name of the event.

event?Dictionary

A dictionary of keys and values to add to the Titanium.Event object sent to the listeners.

Indicates whether indexing is supported by the device.

Returns Boolean

Inherited from Titanium.Proxy

Removes the specified callback as an event listener for the named event.

Parameters
ParametersTypeDescription
nameString

Name of the event.

callbackCallback<Titanium.Event>

Callback function to remove. Must be the same function passed to addEventListener.

4 fields
bubbles Boolean

True if the event will try to bubble up if possible.

cancelBubble Boolean

Set to true to stop the event from bubbling.

source Object

Source object that fired the event.

type String

Name of the event fired.