All Projects → jdmunro → react-native-spotlight-search

jdmunro / react-native-spotlight-search

Licence: MIT license
A React Native module for iOS that provides Spotlight search functionality.

Programming Languages

java
68154 projects - #9 most used programming language
objective c
16641 projects - #2 most used programming language
C++
36643 projects - #6 most used programming language
javascript
184084 projects - #8 most used programming language
Objective-C++
1391 projects
ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to react-native-spotlight-search

Wshp
Code for CVPR'18 spotlight "Weakly and Semi Supervised Human Body Part Parsing via Pose-Guided Knowledge Transfer"
Stars: ✭ 273 (+131.36%)
Mutual labels:  spotlight
Leader Line
Draw a leader line in your web page.
Stars: ✭ 1,872 (+1486.44%)
Mutual labels:  spotlight
Multilamp
Android library to showcase/highlight the multiple views on same overlay
Stars: ✭ 233 (+97.46%)
Mutual labels:  spotlight
Flow.launcher
Launch apps with greater control, search files effortlessly and extend features with community plugins. Fast and fluid productivity tool of choice that helps your workflow.
Stars: ✭ 288 (+144.07%)
Mutual labels:  spotlight
Enlighten
💡 An integrated spotlight-based onboarding and help library for macOS, written in Swift.
Stars: ✭ 44 (-62.71%)
Mutual labels:  spotlight
Zazu
🚀 A fully extensible and open source launcher for hackers, creators and dabblers.
Stars: ✭ 2,060 (+1645.76%)
Mutual labels:  spotlight
arvis
Extendable cross-platform launcher that aims to help you run, edit, create any workflow simply
Stars: ✭ 39 (-66.95%)
Mutual labels:  spotlight
KatSearch
Fast, simple, powerful filesystem search for macOS, just like the good ol' days.
Stars: ✭ 86 (-27.12%)
Mutual labels:  spotlight
Autocomplete
🔮 Fast and full-featured autocomplete library
Stars: ✭ 1,268 (+974.58%)
Mutual labels:  spotlight
Awesomespotlightview
Awesome tool for create tutorial walkthrough or coach tour
Stars: ✭ 225 (+90.68%)
Mutual labels:  spotlight
Wox
Launcher for Windows, an alternative to Alfred and Launchy.
Stars: ✭ 21,122 (+17800%)
Mutual labels:  spotlight
Dext
🔍 A smart launcher. Powered by JavaScript.
Stars: ✭ 713 (+504.24%)
Mutual labels:  spotlight
Spotlight Desktop
Simple app to change the desktop wallpaper to the Windows Spotlight Lock Screen image.
Stars: ✭ 176 (+49.15%)
Mutual labels:  spotlight
Spotlight
Android Library that lights items for tutorials or walk-throughs etc...
Stars: ✭ 3,143 (+2563.56%)
Mutual labels:  spotlight
spotlight-never-index
Exclude some folders from Spotlight.app
Stars: ✭ 21 (-82.2%)
Mutual labels:  spotlight
react-native-search-api
The SearchApi module gives you a general React Native interface to interact with the iOS Search API, Core Spotlight.
Stars: ✭ 35 (-70.34%)
Mutual labels:  spotlight
Driver.js
A light-weight, no-dependency, vanilla JavaScript engine to drive the user's focus across the page
Stars: ✭ 13,154 (+11047.46%)
Mutual labels:  spotlight
Flashlight
🔎 Enhance Spotlight with plugins on macOS
Stars: ✭ 1,118 (+847.46%)
Mutual labels:  spotlight
security-slacker
Pokes users about outstanding security risks found by Crowdstrike Spotlight or vmware Workspace ONE so they secure their own endpoint.
Stars: ✭ 22 (-81.36%)
Mutual labels:  spotlight
Spotlightify
The Spotify overlay controller
Stars: ✭ 190 (+61.02%)
Mutual labels:  spotlight

react-native-spotlight-search

🌟 This project is looking for maintainers! If you're interested to help maintain this repository by fixing bugs, updating dependencies and reviewing other contributions, please open an issue in the repository with a little bit about yourself 🌟

A React Native module for iOS that provides Spotlight search functionality. This allows you to index content from within your React Native app so that it appears in the iOS device's Spotlight search index, potentially increasing the exposure of your app.

Current Features

  • Adding items.
  • Updating items.
  • Deleting items.
  • Register a callback to handle when a search item is tapped.
  • Support for images

Spotlight Search Demo

Installation

With yarn (recommended): $ yarn add react-native-spotlight-search

Or with NPM: $ npm install react-native-spotlight-search --save

iOS

Expo

Prebuild Plugin

This package cannot be used in the "Expo Go" app because it requires custom native code.

After installing this npm package, add the config plugin to the plugins array of your app.json or app.config.js:

{
  "expo": {
    "plugins": ["react-native-spotlight-search"]
  }
}

Next, rebuild your app as described in the "Adding custom native code" guide.

RN >= 0.60

Auto linking or Manually below

RN < 0.60

react-native link react-native-spotlight-search or Manually below

Simply add RCTSpotlightSearch.xcodeproj to Libraries and add libRCTSpotlightSearch.a to Link Binary With Libraries under Build Phases. More info and screenshots about how to do this is available in the React Native documentation.

In Your AppDelegate (Optional)

If you wish to be able to handle search item tapped callbacks, you'll need to add the following code to your AppDelegate file:

#import "RCTSpotlightSearch.h"

- (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity restorationHandler:(nonnull void (^)(NSArray * _Nullable))restorationHandler {
  [RCTSpotlightSearch handleContinueUserActivity:userActivity];
  return YES;
}

If Xcode complains about being unable to find the header file, please ensure that your project's header search includes the following:

$(SRCROOT)/../node_modules/react-native-spotlight-search

Like this:

Header Search Paths

Usage

First up, import the module:

import SpotlightSearch from "react-native-spotlight-search";

Indexing Items

You can either add an array of items:

SpotlightSearch.indexItems([
  {
    title: "Strawberry",
    contentDescription: "A sweet and juicy fruit.",
    uniqueIdentifier: "1",
    domain: "fruit",
    thumbnailName: "strawberry",
  },
  {
    title: "Kiwi",
    contentDescription: "Not a type of bird.",
    uniqueIdentifier: "2",
    domain: "fruit",
    thumbnailName: "kiwi",
  },
]);

Or individual items:

SpotlightSearch.indexItem({
  title: "Strawberry",
  contentDescription: "A sweet and juicy fruit.",
  uniqueIdentifier: "1",
  thumbnailName: "strawberry",
});

Search Item Properties

Property Description Type Required
title The title of the search item. string Yes
contentDescription A description which appears below the title in the search results. string No
uniqueIdentifier A unique and stable identifier. Used to refer to the item. string Yes
domain A string for grouping related items together in a way that makes sense. Not displayed to the user. string Yes
thumbnailName A local file name/key to a thumbnail image. See A Note About Thumbnails. string No
thumbnailData A base64 string representation of a thumbnail image. See A Note About Thumbnails. string No
keywords An array of keywords which can be used to help inform the search index. Not visible to the user. [string] No

Updating Items

Simply use the same method as adding items. Be sure to reference the same key when indexing the item so that any new metadata changes will be reflected in the Spotlight index.

Removing Items

Items can be removed by identifier:

SpotlightSearch.deleteItemsWithIdentifiers(["1", "2"]);

Or by domain:

SpotlightSearch.deleteItemsInDomains(["fruit"]);

Alternatively, you can delete all items indexed by your app:

SpotlightSearch.deleteAllItems();

Promises

All API index and delete methods are asynchronous and return promises. You can chain things like this:

SpotlightSearch.deleteAllItems().then(() => {
  SpotlightSearch.indexItem({
    title: "Strawberry",
    contentDescription: "A sweet and juicy fruit.",
    uniqueIdentifier: "1",
    thumbnailName: "strawberry",
  });
});

Handling User Interactions

You can choose to add a custom handler that will be invoked in the event of a user tapping one of the search items in the Spotlight results:

SpotlightSearch.searchItemTapped((uniqueIdentifier) => {
  alert(`You tapped on ${uniqueIdentifier}!`);
});

Optionally, if you want to capture the search item that was tapped to open the app (perhaps the listener was set after the event was triggered):

SpotlightSearch.getInitialSearchItem().then((uniqueIdentifier) => {
  alert(`You tapped on ${uniqueIdentifier} and opened the app!`);
});

The parameter will be the uniqueIdentifier that the item was indexed with. You can use this to lookup the item and display information about it, e.g. by navigating to a relevant page in your app.

A Note About Thumbnails

Currently, in order to use an image path it must exist locally on the device in the project assets folder. This is a limitation of iOS rather than of this library.

To use images that are not in your assets folder (local or remote files), read them as base64 and include the string value using the thumbnailData property.

To-do

  • Support additional built in types (location etc).
  • Public links.
  • Initial release.
  • New iOS 10 features.

PRs welcome ❤️

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].