Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TIMOB:19006 Implement Core Spotlight #7029

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
107 changes: 107 additions & 0 deletions apidoc/Titanium/App/iOS/SearchableIndex.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
---
name: Titanium.App.iOS.SearchableIndex
description: |
The SearchableIndex module is used to add or remove Ti.App.iOS.SearchableItem object from the device search index.
To effectively add and remove information from the iOS search index you will need to use the below listed modules:

* Ti.App.iOS.SearchableItemAttributeSet - Used to create meta data related to the Titanium.App.iOS.SearchableItem
* Ti.App.iOS.SearchableItem - Used to assemble meta data into a unique object package to be used by Ti.App.iOS.SearchableIndex
* Ti.App.iOS.SearchableIndex - Used to add and remove Ti.App.iOS.SearchableItem objects to the device search index

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

extends: Titanium.Proxy
platforms: [iphone,ipad]
since: "4.3.0"
createable: true
methods:
- name: isSupported
summary: Indicates whether indexing is supported by the device.
returns:
type: Boolean
platforms: [iphone, ipad]
osver: {ios: {min: "9.0"}}

- name: AddToDefaultSearchableIndex
summary: |
Adds an array of Titanium.App.iOS.SearchableItem to the default search index.
parameters:
- name: Array
summary: Provides an array of Titanium.App.iOS.SearchableItem to be added to the default search index.
type: Array<Titanium.App.iOS.SearchableItem>
- name: callback
summary: Function to invoke on success or failure of add the array Titanium.App.iOS.SearchableItem to the default search index.
type: Callback<Dictionary>
platforms: [iphone, ipad]
osver: {ios: {min: "9.0"}}

- name: deleteAllSearchableItems
summary: |
Removes all search items added by the application.
parameters:
- name: callback
summary: Function to invoke on success or failure of deleting all search items.
type: Callback<Dictionary>
platforms: [iphone, ipad]
osver: {ios: {min: "9.0"}}

- name: deleteAllSearchableItemByDomainIdenifiers
summary: |
Removes search items based on an array of domainIdentifiers.
parameters:
- name: Array
summary: Provides an array of domainIdentifiers to be removed from the default search index.
type: Array<String>
- name: callback
summary: Function to invoke on success or failure of removing search items from the default search index.
type: Callback<Dictionary>
platforms: [iphone, ipad]
osver: {ios: {min: "9.0"}}

- name: deleteSearchableItemsByIdentifiers
summary: |
Removes search items based on an array of identifiers.
parameters:
- name: Array
summary: Provides an array of identifiers to be removed from the default search index.
type: Array<String>
- name: callback
summary: Function to invoke on success or failure of removing search items from the default search index.
type: Callback<Dictionary>
platforms: [iphone, ipad]
osver: {ios: {min: "9.0"}}
examples:
- title: Creating a new SearchableIndex Example
example: |
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
Ti.App.iOS.SearchableIndex is used to add the Ti.App.iOS.SearchableItem to the default search index.

#### app.js

var searchItems = [];
var itemAttr = Ti.App.iOS.createSearchableItemAttributeSet({
itemContentType:"public.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));
}
});


77 changes: 77 additions & 0 deletions apidoc/Titanium/App/iOS/SearchableItem.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
name: Titanium.App.iOS.SearchableItem
description: |
The SearchableItem module is used to create a unique object containing all of the search information that will
appear in the device search index. To effectively add and remove information from the iOS search index
you will need to use the below listed modules:

* Ti.App.iOS.SearchableItemAttributeSet - Used to create meta data related to the Titanium.App.iOS.SearchableItem
* Ti.App.iOS.SearchableItem - Used to assemble meta data into a unique object package to be used by Ti.App.iOS.SearchableIndex
* Ti.App.iOS.SearchableIndex - Used to add and remove Ti.App.iOS.SearchableItem objects to the device search index

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

extends: Titanium.Proxy
platforms: [iphone,ipad]
since: "4.3.0"
createable: true
properties:
- name: uniqueIdentifier
summary: Unique to your application group
type: String
availability: creation
osver: {ios: {min: "9.0"}}
platforms: [iphone,ipad]
- name: domainIdentifier
summary: Identifier that represents the "domain" or owner of this item.
type: String
osver: {ios: {min: "9.0"}}
platforms: [iphone,ipad]
- name: expirationDate
summary: Searchable items have an expiration date or time to live. By default it's set to 1 month..
description: |
Absolute date after which this activity is no longer eligible to be indexed or handed off.

When setting this property the Date format accepted is: "_yyyy_-_MM_-_dd_**T**_HH_**:**_mm_**:**_ss_**.**_SSS_**+0000**"

When reading this property Date values will be returned as String in the format: "_yyyy_-_MM_-_dd_**T**_HH_**:**_mm_**:**_ss_**.**_SSS_**+0000**"

type: String
osver: {ios: {min: "9.0"}}
platforms: [iphone,ipad]
examples:
- title: Creating a new SearchableItem Example
example: |
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
Ti.App.iOS.SearchableIndex is used to add the Ti.App.iOS.SearchableItem to the default search index.

#### app.js

var searchItems = [];
var itemAttr = Ti.App.iOS.createSearchableItemAttributeSet({
itemContentType:"public.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));
}
});