{"id":23916679,"url":"https://github.com/jdmunro/react-native-spotlight-search","last_synced_at":"2025-04-05T22:04:12.957Z","repository":{"id":9488271,"uuid":"61663155","full_name":"jdmunro/react-native-spotlight-search","owner":"jdmunro","description":"A React Native module for iOS that provides Spotlight search functionality.","archived":false,"fork":false,"pushed_at":"2023-03-18T08:53:52.000Z","size":2489,"stargazers_count":127,"open_issues_count":22,"forks_count":22,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-04-13T21:56:54.116Z","etag":null,"topics":["es6","ios","objective-c","plugin","react-native","search","spotlight"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jdmunro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-06-21T19:59:06.000Z","updated_at":"2024-06-20T23:21:57.961Z","dependencies_parsed_at":"2024-06-20T23:21:34.325Z","dependency_job_id":"eeed4bd3-5b90-4288-b52b-c290ebb5a253","html_url":"https://github.com/jdmunro/react-native-spotlight-search","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdmunro%2Freact-native-spotlight-search","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdmunro%2Freact-native-spotlight-search/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdmunro%2Freact-native-spotlight-search/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdmunro%2Freact-native-spotlight-search/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jdmunro","download_url":"https://codeload.github.com/jdmunro/react-native-spotlight-search/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247406085,"owners_count":20933803,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["es6","ios","objective-c","plugin","react-native","search","spotlight"],"created_at":"2025-01-05T12:13:17.948Z","updated_at":"2025-04-05T22:04:12.937Z","avatar_url":"https://github.com/jdmunro.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-native-spotlight-search\n\n## 🌟 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 🌟\n\nA 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.\n\n## Current Features\n\n- Adding items.\n- Updating items.\n- Deleting items.\n- Register a callback to handle when a search item is tapped.\n- Support for images\n\n![Spotlight Search Demo](http://i.imgur.com/tbI3yAs.gif)\n\n## Installation\n\nWith yarn (recommended):\n`$ yarn add react-native-spotlight-search`\n\nOr with NPM:\n`$ npm install react-native-spotlight-search --save`\n\n### iOS\n\n#### Expo\n\n\u003ch2 align=\"center\"\u003ePrebuild Plugin\u003c/h2\u003e\n\n\u003e This package cannot be used in the \"Expo Go\" app because [it requires custom native code](https://docs.expo.io/workflow/customizing/).\n\nAfter installing this npm package, add the [config plugin](https://docs.expo.io/guides/config-plugins/) to the [`plugins`](https://docs.expo.io/versions/latest/config/app/#plugins) array of your `app.json` or `app.config.js`:\n\n```json\n{\n  \"expo\": {\n    \"plugins\": [\"react-native-spotlight-search\"]\n  }\n}\n```\n\nNext, rebuild your app as described in the [\"Adding custom native code\"](https://docs.expo.io/workflow/customizing/) guide.\n\n#### RN \u003e= 0.60\n\nAuto linking or Manually below\n\n#### RN \u003c 0.60\n\n`react-native link react-native-spotlight-search` or Manually below\n\nSimply 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](http://facebook.github.io/react-native/docs/linking-libraries-ios.html#content).\n\n### In Your AppDelegate (Optional)\n\nIf you wish to be able to handle search item tapped callbacks, you'll need to add the following code to your AppDelegate file:\n\n```objc\n#import \"RCTSpotlightSearch.h\"\n\n- (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity restorationHandler:(nonnull void (^)(NSArray * _Nullable))restorationHandler {\n  [RCTSpotlightSearch handleContinueUserActivity:userActivity];\n  return YES;\n}\n```\n\nIf Xcode complains about being unable to find the header file, please ensure that your project's header search includes the following:\n\n`$(SRCROOT)/../node_modules/react-native-spotlight-search`\n\nLike this:\n\n![Header Search Paths](http://i.imgur.com/r69EMcQ.png)\n\n## Usage\n\nFirst up, import the module:\n\n```js\nimport SpotlightSearch from \"react-native-spotlight-search\";\n```\n\n### Indexing Items\n\nYou can either add an array of items:\n\n```js\nSpotlightSearch.indexItems([\n  {\n    title: \"Strawberry\",\n    contentDescription: \"A sweet and juicy fruit.\",\n    uniqueIdentifier: \"1\",\n    domain: \"fruit\",\n    thumbnailName: \"strawberry\",\n  },\n  {\n    title: \"Kiwi\",\n    contentDescription: \"Not a type of bird.\",\n    uniqueIdentifier: \"2\",\n    domain: \"fruit\",\n    thumbnailName: \"kiwi\",\n  },\n]);\n```\n\nOr individual items:\n\n```js\nSpotlightSearch.indexItem({\n  title: \"Strawberry\",\n  contentDescription: \"A sweet and juicy fruit.\",\n  uniqueIdentifier: \"1\",\n  thumbnailName: \"strawberry\",\n});\n```\n\n#### Search Item Properties\n\n| Property                 | Description                                                                                                   | Type       | Required |\n| ------------------------ | ------------------------------------------------------------------------------------------------------------- | ---------- | -------- |\n| **`title`**              | The title of the search item.                                                                                 | `string`   | Yes      |\n| **`contentDescription`** | A description which appears below the title in the search results.                                            | `string`   | No       |\n| **`uniqueIdentifier`**   | A unique and stable identifier. Used to refer to the item.                                                    | `string`   | Yes      |\n| **`domain`**             | A string for grouping related items together in a way that makes sense. Not displayed to the user.            | `string`   | Yes      |\n| **`thumbnailName`**      | A local file name/key to a thumbnail image. See [A Note About Thumbnails](#a-note-about-thumbnails).          | `string`   | No       |\n| **`thumbnailData`**      | A base64 string representation of a thumbnail image. See [A Note About Thumbnails](#a-note-about-thumbnails). | `string`   | No       |\n| **`keywords`**           | An array of keywords which can be used to help inform the search index. Not visible to the user.              | `[string]` | No       |\n\n### Updating Items\n\nSimply 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.\n\n### Removing Items\n\nItems can be removed by identifier:\n\n```js\nSpotlightSearch.deleteItemsWithIdentifiers([\"1\", \"2\"]);\n```\n\nOr by domain:\n\n```js\nSpotlightSearch.deleteItemsInDomains([\"fruit\"]);\n```\n\nAlternatively, you can delete _all_ items indexed by your app:\n\n```js\nSpotlightSearch.deleteAllItems();\n```\n\n### Promises\n\nAll API index and delete methods are asynchronous and return promises. You can chain things like this:\n\n```js\nSpotlightSearch.deleteAllItems().then(() =\u003e {\n  SpotlightSearch.indexItem({\n    title: \"Strawberry\",\n    contentDescription: \"A sweet and juicy fruit.\",\n    uniqueIdentifier: \"1\",\n    thumbnailName: \"strawberry\",\n  });\n});\n```\n\n### Handling User Interactions\n\nYou 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:\n\n```js\nSpotlightSearch.searchItemTapped((uniqueIdentifier) =\u003e {\n  alert(`You tapped on ${uniqueIdentifier}!`);\n});\n```\n\nOptionally, 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):\n\n```js\nSpotlightSearch.getInitialSearchItem().then((uniqueIdentifier) =\u003e {\n  alert(`You tapped on ${uniqueIdentifier} and opened the app!`);\n});\n\n// example in a useEffect with listener cleanup\nuseEffect(() =\u003e {\n    const spotlightListener = SpotlightSearch.searchItemTapped((uniqueIdentifier) =\u003e {\n        alert(`You tapped on ${uniqueIdentifier} and opened the app!`);\n    })\n    return () =\u003e {\n        // cleanup listener\n        spotlightListener.remove()\n    }\n}, [])\n```\n\nThe 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.\n\n## A Note About Thumbnails\n\nCurrently, 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.\n\nTo use images that are not in your assets folder (local or remote files), read them as\nbase64 and include the string value using the `thumbnailData` property.\n\n## To-do\n\n- Support additional built in types (location etc).\n- Public links.\n- Initial release.\n- New iOS 10 features.\n\nPRs welcome ❤️\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdmunro%2Freact-native-spotlight-search","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjdmunro%2Freact-native-spotlight-search","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdmunro%2Freact-native-spotlight-search/lists"}