Need help upgrading to Ionic Framework 4.0? Get assistance with our Enterprise Migration Services EXPLORE NOW

Index App Content

Improve this doc

This plugin gives you a Javascript API to interact with Core Spotlight on iOS (=> iOS 9). You can add, update and delete items to the spotlight search index. Spotlight Search will include these items in the result list. You can deep-link the search results with your app.

Repo: https://github.com/johanblomgren/cordova-plugin-indexappcontent

Installation

  1. Install the Cordova and Ionic Native plugins:
    $ ionic cordova plugin add cordova-plugin-indexappcontent
    $ npm install --save @ionic-native/index-app-content@4
    
  2. Add this plugin to your app's module

Supported platforms

Usage

import { IndexAppContent } from '@ionic-native/index-app-content';


constructor(private indexAppContent: IndexAppContent) { }

...

var items = [
     {
       domain: 'com.my.domain',
       identifier: '88asdf7dsf',
       title: 'Foo',
       description: 'Bar',
       url: 'http://location/of/my/image.jpg',
   },
   {
       domain: 'com.other.domain',
       identifier: '9asd67g6a',
       title: 'Baz',
       description: 'Woot',
       url: 'http://location/of/my/image2.jpg',
    }
];

this.indexAppContent.setItems(items)
  .then((res: any) => console.log(res))
  .catch((error: any) => console.error(error));

Instance Members

isIndexingAvailable()

The option to index app content might not be available at all due to device limitations or user settings. Therefore it’s highly recommended to check upfront if indexing is possible.

Returns: Promise<boolean> Returns a promise that resolves with true if indexing is available, false if not

setItems(Array)

Add or change items to spotlight index

Param Type Details
Array Array<IndexItem>

of items to index

Returns: Promise<any> Returns if index set was successful

clearItemsForDomains(Array)

Clear all items stored for a given array of domains

Param Type Details
Array Array<string>

of domains to clear

Returns: Promise<any> Resolve if successful

clearItemsForIdentifiers(Array)

Clear all items stored for a given array of identifiers

Param Type Details
Array Array<string>

of identifiers to clear

Returns: Promise<any> Resolve if successful

onItemPressed()

If user taps on a search result in spotlight then the app will be launched. You can register a Javascript handler to get informed when this happens.

Returns: Observable<any> returns an observable that notifies you when he user presses on the home screen icon

setIndexingInterval(Numeric)

You might want to avoid to update spotlight index too frequently. Without calling this function a subsequent call to manipulate the index is only possible after 1440 minutes (= 24 hours)!

Param Type Details
Numeric number

value => 0

API

Native

General