react-native-search-api
Advanced tools
Comparing version 1.0.3 to 1.1.0
23
index.js
import { NativeModules, NativeEventEmitter } from 'react-native'; | ||
import resolveAssetSource from 'react-native/Libraries/Image/resolveAssetSource'; | ||
const SearchApiManager = NativeModules.SearchApiManager; | ||
@@ -27,4 +29,5 @@ | ||
* | ||
* #### thumbnailURL: string | ||
* URL of the thumbnail, presented in the search results. Optional. | ||
* #### thumbnail: string|object | ||
* Image to be used as the thumbnail. Same as the `source` value of the `Image` | ||
* view. Optional. | ||
* | ||
@@ -122,3 +125,3 @@ * ### Spotlight-specific keys | ||
indexSpotlightItem(item: Object): Promise { | ||
return SearchApiManager.indexItem(item); | ||
return this.indexSpotlightItems([item]); | ||
} | ||
@@ -129,7 +132,8 @@ | ||
* | ||
* @param item An array with new items to be added. | ||
* @param items An array with new items to be added. | ||
* See the comment above this class for more info. | ||
*/ | ||
indexSpotlightItems(items: Array): Promise { | ||
return SearchApiManager.indexItems(items); | ||
var copies = items.map(item => resolveItemThumbnail(item)); | ||
return SearchApiManager.indexItems(copies); | ||
} | ||
@@ -170,3 +174,4 @@ | ||
indexAppHistoryItem(item: Object): Promise { | ||
return SearchApiManager.createUserActivity(item); | ||
var itemCopy = resolveItemThumbnail(item); | ||
return SearchApiManager.createUserActivity(itemCopy); | ||
} | ||
@@ -176,2 +181,8 @@ | ||
function resolveItemThumbnail(item: Object): Object { | ||
var itemCopy = JSON.parse(JSON.stringify(item)); | ||
itemCopy.thumbnail = resolveAssetSource(item.thumbnail); | ||
return itemCopy; | ||
} | ||
export default new SearchApi(); |
@@ -7,3 +7,3 @@ { | ||
}, | ||
"version": "1.0.3", | ||
"version": "1.1.0", | ||
"description": "A React Native module that allows to perform the Spotlight integration on iOS", | ||
@@ -10,0 +10,0 @@ "author": "Daniil Konoplev <danchoys@ombori.com>", |
@@ -17,3 +17,3 @@ # React Native Search Api module | ||
To the top of your `AppDelegate.m` add the following line: | ||
``` | ||
```objc | ||
#import "RCTSearchApiManager.h" | ||
@@ -23,3 +23,3 @@ ``` | ||
In your AppDelegate implementation add the following: | ||
``` | ||
```objc | ||
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler { | ||
@@ -33,3 +33,3 @@ return [RCTSearchApiManager application:application continueUserActivity:userActivity restorationHandler:restorationHandler]; | ||
Subscribe to the search item open events in your components like this: | ||
``` | ||
```js | ||
componentDidMount() { | ||
@@ -43,3 +43,3 @@ <...> | ||
To prevent memory leaks don't forget to unsubscribe: | ||
``` | ||
```js | ||
componentWillUnmount() { | ||
@@ -53,3 +53,3 @@ <...> | ||
In order to create a new spotlight item, use `indexSpotlightItem` or `indexSpotlightItems`: | ||
``` | ||
```js | ||
SearchApi.indexSpotlightItem(item).then(result => { | ||
@@ -63,3 +63,3 @@ console.log('Success'); | ||
To add new items to the app history, use `createUserActivity`: | ||
``` | ||
```js | ||
SearchApi.indexAppHistoryItem(item).then(result => { | ||
@@ -83,21 +83,22 @@ console.log('Success'); | ||
##### title: string | ||
##### `title`: string | ||
Title of the item. Required for both item types. | ||
##### contentDescription: string | ||
##### `contentDescription`: string | ||
Description of the item. Optional. | ||
##### keywords: Array<string> | ||
##### `keywords`: Array<string> | ||
An array of keywords, assigned to the search item. Optional. | ||
##### thumbnailURL: string | ||
URL of the thumbnail, presented in the search results. Optional. | ||
##### `thumbnail`: string|int|object | ||
Thumbnail to be presented in the search results. The same format as `source` in | ||
the `Image` component. Refer to [documentation](https://facebook.github.io/react-native/docs/image.html). Optional. | ||
### Spotlight-specific keys | ||
##### uniqueIdentifier: string | ||
##### `uniqueIdentifier`: string | ||
The unique identifier of the spotlight item, passed later on during | ||
the item opening event. Required. | ||
##### domain: string | ||
##### `domain`: string | ||
The domain for the spotlight item. Optional. | ||
@@ -107,16 +108,16 @@ | ||
##### userInfo: Object | ||
##### `userInfo`: Object | ||
A dictionary, passed later on during the item opening event. Required. | ||
##### eligibleForPublicIndexing: boolean | ||
##### `eligibleForPublicIndexing`: boolean | ||
A flag, that when set to `true` allows to add the item to the public index. | ||
Optional. | ||
##### expirationDate: Date | ||
##### `expirationDate`: Date | ||
Expiration date of the user activity item. Optional. | ||
##### webpageURL: string | ||
##### `webpageURL`: string | ||
URL of the page, representing the same content on the app's website. | ||
## Credits | ||
Ombori Group AB | ||
[© 2017 PresenceKit by Ombori AB](https://ombori.com/) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33616
165
116
1