Skip to content

Commit eca28dc

Browse files
authored
Merge pull request #14 from soundgym/master
support RN 0.60.x
2 parents 5d398bc + 8770e03 commit eca28dc

File tree

4 files changed

+56
-11
lines changed

4 files changed

+56
-11
lines changed

README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,18 @@ A React Native module for iOS that provides Spotlight search functionality. This
1515
## Installation
1616

1717
With yarn (recommended):
18-
1918
`$ yarn add react-native-spotlight-search`
2019

2120
Or with NPM:
22-
2321
`$ npm install react-native-spotlight-search --save`
2422

2523
### iOS
2624

27-
#### With `react-native link`
28-
29-
`$ react-native link`
25+
#### RN >= 0.60
26+
Auto linking or Manually below
3027

31-
#### Manually
28+
#### RN < 0.60
29+
`react-native link react-native-spotlight-search` or Manually below
3230

3331
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](http://facebook.github.io/react-native/docs/linking-libraries-ios.html#content).
3432

index.js

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,38 @@
1-
import {NativeModules, NativeEventEmitter} from 'react-native';
1+
import {NativeModules, NativeEventEmitter, Platform} from 'react-native';
22

33
const {SpotlightSearch} = NativeModules;
4-
54
const spotlightEventEmitter = new NativeEventEmitter(SpotlightSearch);
65

7-
SpotlightSearch.searchItemTapped = (callback) => spotlightEventEmitter.addListener('spotlightSearchItemTapped', callback);
6+
const EVENT_ITEM_TAPPED = 'spotlightSearchItemTapped';
7+
const nullFunc = () => {};
88

9-
export default SpotlightSearch;
9+
export default {
10+
getInitialSearchItem: Platform.select({
11+
ios: SpotlightSearch?.getInitialSearchItem,
12+
android: nullFunc
13+
}),
14+
indexItem: Platform.select({
15+
ios: (item) => SpotlightSearch?.indexItem(item),
16+
android: nullFunc
17+
}),
18+
indexItems: Platform.select({
19+
ios: (items) => SpotlightSearch?.indexItems(items),
20+
android: nullFunc
21+
}),
22+
deleteItemsWithIds: Platform.select({
23+
ios: (ids) => SpotlightSearch?.deleteItemsWithIdentifiers(ids),
24+
android: nullFunc
25+
}),
26+
deleteItemsInDomains: Platform.select({
27+
ios: (domains) => SpotlightSearch?.deleteItemsInDomains(domains),
28+
android: nullFunc
29+
}),
30+
deleteAllItems: Platform.select({
31+
ios: SpotlightSearch?.deleteAllItems,
32+
android: nullFunc
33+
}),
34+
searchItemTapped: Platform.select({
35+
ios: (callback) => spotlightEventEmitter?.addListener(EVENT_ITEM_TAPPED, callback),
36+
android: nullFunc
37+
}),
38+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-spotlight-search",
3-
"version": "1.1.0",
3+
"version": "1.1.1",
44
"description": "A React Native module for iOS that provides Spotlight search functionality.",
55
"main": "index.js",
66
"files": [
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
require 'json'
2+
3+
package = JSON.parse(File.read(File.join(__dir__,'package.json')))
4+
5+
Pod::Spec.new do |s|
6+
s.name = package['name']
7+
s.version = package['version']
8+
s.summary = package['description']
9+
10+
s.authors = package['author']
11+
s.homepage = "https://github.com/jdmunro/react-native-spotlight-search#readme"
12+
s.license = package['license']
13+
s.platform = :ios, "9.0"
14+
15+
s.source = { :git => "https://github.com/jdmunro/react-native-spotlight-search.git", :tag => "v#{s.version}" }
16+
s.source_files = "ios/**/*.{h,m}"
17+
s.dependency 'React'
18+
end

0 commit comments

Comments
 (0)