{"id":4614,"url":"https://github.com/hassellof/react-native-search-api","last_synced_at":"2025-09-05T17:46:54.406Z","repository":{"id":20951608,"uuid":"91334314","full_name":"hassellof/react-native-search-api","owner":"hassellof","description":"The SearchApi module gives you a general React Native interface to interact with the iOS Search API, Core Spotlight.","archived":false,"fork":false,"pushed_at":"2020-04-20T07:42:04.000Z","size":24,"stargazers_count":37,"open_issues_count":2,"forks_count":10,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-08-30T23:14:22.758Z","etag":null,"topics":["history","ios","react-native","search","spotlight"],"latest_commit_sha":null,"homepage":"","language":"Objective-C","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/hassellof.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}},"created_at":"2017-05-15T12:18:16.000Z","updated_at":"2025-05-09T05:09:39.000Z","dependencies_parsed_at":"2022-07-23T15:32:12.039Z","dependency_job_id":null,"html_url":"https://github.com/hassellof/react-native-search-api","commit_stats":null,"previous_names":["ombori/react-native-search-api"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/hassellof/react-native-search-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hassellof%2Freact-native-search-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hassellof%2Freact-native-search-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hassellof%2Freact-native-search-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hassellof%2Freact-native-search-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hassellof","download_url":"https://codeload.github.com/hassellof/react-native-search-api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hassellof%2Freact-native-search-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273794551,"owners_count":25169636,"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","status":"online","status_checked_at":"2025-09-05T02:00:09.113Z","response_time":402,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["history","ios","react-native","search","spotlight"],"created_at":"2024-01-05T20:17:17.960Z","updated_at":"2025-09-05T17:46:54.363Z","avatar_url":"https://github.com/hassellof.png","language":"Objective-C","funding_links":[],"categories":["Components"],"sub_categories":["System"],"readme":"# React Native Search Api module\n\nThe `SearchApi` module gives you a general React Native interface to interact with the iOS Search API, Core Spotlight.\n\nFor more information about iOS Search APIs, see [https://developer.apple.com/ios/search/](https://developer.apple.com/ios/search/).\n\n## Installation\n\n### Automatic part\n\n1. `npm install react-native-search-api --save`\n1. `react-native link`\n\n### Manual part\n\nTo the top of your `AppDelegate.m` add the following line:\n```objc\n#import \"RCTSearchApiManager.h\"\n```\n\nIn your AppDelegate implementation add the following:\n```objc\n- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler {\n    return [RCTSearchApiManager application:application continueUserActivity:userActivity restorationHandler:restorationHandler];\n}\n```\n\n## Usage\n\nSubscribe to the search item open events in your components like this:\n```js\ncomponentDidMount() {\n    \u003c...\u003e\n    SearchApi.addOnSpotlightItemOpenEventListener(this.handleOnSpotlightItemOpenEventListener);\n    SearchApi.addOnAppHistoryItemOpenEventListener(this.handleOnAppHistoryItemOpenEventListener);\n}\n```\n\nTo prevent memory leaks don't forget to unsubscribe:\n```js\ncomponentWillUnmount() {\n    \u003c...\u003e\n    SearchApi.removeOnSpotlightItemOpenEventListener(this.handleOnSpotlightItemOpenEventListener);\n    SearchApi.removeOnAppHistoryItemOpenEventListener(this.handleOnAppHistoryItemOpenEventListener)\n}\n```\n\nGenerally you should be interested whether the app was started using the search, therefore consider using\nthe following two methods:\n```js\n// For the spotlight item:\nSearchApi.getInitialSpotlightItem().then(result =\u003e {\n    if (result) {\n        console.log('Started with a spotlight item!')\n    }\n})\n// For the app history item:\nSearchApi.getInitialAppHistoryItem().then(result =\u003e {\n    if (result) {\n        console.log('Started with an app history item!')\n    }\n})\n```\n\nIn order to create a new spotlight item, use `indexSpotlightItem` or `indexSpotlightItems`:\n```js\nSearchApi.indexSpotlightItem(item).then(result =\u003e {\n    console.log('Success');\n}).catch(err =\u003e {\n    console.log('Error: ' + err);\n});\n```\n\nTo add new items to the app history, use `createUserActivity`:\n```js\nSearchApi.indexAppHistoryItem(item).then(result =\u003e {\n    console.log('Success');\n    that.setState({labelText: 'Success'});\n}).catch(err =\u003e {\n    console.log('Error: ' + err);\n    that.setState({labelText: ('Error: ' + err)});\n});\n```\n\nThe parameters, that items may specify are listed below:\n\n## Search item keys\n\nDictionaries, passed to create spotlight and app history items have some common\nand some specific keys, here is the list of all possible keys.\n\n### Common keys\n\n##### `title`: string\nTitle of the item. Required for both item types.\n\n##### `contentDescription`: string\nDescription of the item. Optional.\n\n##### `keywords`: Array\u003cstring\u003e\nAn array of keywords, assigned to the search item. Optional.\n\n##### `thumbnail`: string|int|object\nThumbnail to be presented in the search results. The same format as `source` in\nthe `Image` component. Optional.\n\nExamples:\n```js\nvar localItem = {\n  \u003c...\u003e,\n  thumbnail: require('/react-native/img/favicon.png')\n};\nvar remoteItem = {\n  \u003c...\u003e,\n  thumbnail: {uri: 'https://facebook.github.io/react-native/docs/assets/favicon.png'}\n};\n```\n\nPlease refer to [documentation](https://facebook.github.io/react-native/docs/image.html) for more details.\n\n### Spotlight-specific keys\n\n##### `uniqueIdentifier`: string\nThe unique identifier of the spotlight item, passed later on during\nthe item opening event. Required.\n\n##### `domain`: string\nThe domain for the spotlight item. Optional.\n\n### App history-specific keys\n\n##### `userInfo`: Object\nA dictionary, passed later on during the item opening event. Required.\n\n##### `eligibleForPublicIndexing`: boolean\nA flag, that when set to `true` allows to add the item to the public index.\nOptional.\n\n##### `expirationDate`: Date\nExpiration date of the user activity item. Optional.\n\n##### `webpageURL`: string\nURL of the page, representing the same content on the app's website.\n\n## Credits\n[© 2017 PresenceKit by Ombori AB](https://ombori.com/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhassellof%2Freact-native-search-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhassellof%2Freact-native-search-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhassellof%2Freact-native-search-api/lists"}