Skip to content

Commit 2979990

Browse files
committed
docs: explain configuration
1 parent b1b94d4 commit 2979990

File tree

1 file changed

+31
-7
lines changed

1 file changed

+31
-7
lines changed

README.md

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,29 @@ Dependencies:
1414
Steps:
1515

1616
1. Make sure `react-native-webview` is installed:
17+
1718
```sh
1819
npx expo install react-native-webview@^13.10.3
1920
```
21+
2022
2. Install the package:
23+
2124
```sh
2225
npm install @provenance/react-native-provenance --save
2326
```
27+
2428
The `--save` option is [important for autolinking](https://reactnative.dev/docs/linking-libraries-ios#automatic-linking).
2529

2630
3. Run:
31+
2732
```sh
2833
npx expo run:android --no-build-cache
2934
```
35+
3036
to ensure native dependencies are linked.
3137

3238
4. Run the app using:
39+
3340
```sh
3441
npx expo start
3542
```
@@ -41,24 +48,43 @@ Note, despite the steps mention Expo, the expo is not necessary, vanilla react-n
4148
#### RNCWebView module could not be found
4249

4350
Use developers build. First, run:
51+
4452
```sh
4553
npx expo run:android --no-build-cache
4654
```
4755

4856
After the error message disappears, you can start emulator with:
57+
4958
```sh
5059
npx expo run:android
5160
```
61+
5262
and switch between the build types from Expo CLI menu.
5363

5464
## Usage
5565

5666
There are 2 ways how to integrate Provenance components:
5767

58-
* The easiest one: by using our built in modal
59-
* Allows more customizations: by using Trust Badge and Bundle separately
68+
- The easiest one: by using our built in modal
69+
- Allows more customizations: by using Trust Badge and Bundle separately
70+
71+
In both cases you will need `apiKey`, `bundleId` and `productSku`.
72+
For `apiKey` and `bundleId` use the same values you may already received from our support team or request those.
6073

61-
In both cases you will need `bundleId` and `productSku` - use the same values you may already received from our support team or from your retail website.
74+
You must call `configure` before rendering the components.
75+
76+
```
77+
import { configure } from "@provenance/react-native-provenance";
78+
79+
configure({
80+
apiKey: process.env.EXPO_PUBLIC_API_KEY,
81+
bundleId: process.env.EXPO_PUBLIC_BUNDLE_ID,
82+
});
83+
```
84+
85+
We recommend reading API_KEY value from the environment variable, like in example above if you use Expo.
86+
87+
`productSku` is a unique identifier of a product, it is the same as on your retail website.
6288

6389
### Using our built in modal
6490

@@ -78,7 +104,7 @@ export function ProductPage () {
78104
<ProductPrice1.99</ProductPrice>
79105
<Button>Add to Basket</Button>
80106

81-
<TrustBadge bundleId={bundleId} sku={productSku} />
107+
<TrustBadge sku={productSku} />
82108

83109
<ProductDescription>
84110
Indulge in the pure essence of nature with our premium organic apples.
@@ -126,7 +152,7 @@ export function ProductPage () {
126152
<ProductPrice1.99</ProductPrice>
127153
<Button>Add to Basket</Button>
128154

129-
<TrustBadge onPress={handleTrustBadgePress} overlay={false} bundleId={bundleId} sku={productSku} />
155+
<TrustBadge onPress={handleTrustBadgePress} overlay={false} sku={productSku} />
130156

131157
<ProductDescription>
132158
Indulge in the pure essence of nature with our premium organic apples.
@@ -149,7 +175,6 @@ export function ProductPage () {
149175
}}
150176
>
151177
<Bundle
152-
bundleId={bundleId}
153178
sku={productSku}
154179
onResized={(newSize: number) => {
155180
setBundleContainerHeight(newSize);
@@ -219,7 +244,6 @@ Just add it to the `getBundleLoadingHeight` and `height` in `onResized` callback
219244

220245
See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
221246

222-
223247
---
224248

225249
Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)

0 commit comments

Comments
 (0)