Skip to content

Commit

Permalink
Merge pull request #529 from breez/savage-rn-example-package
Browse files Browse the repository at this point in the history
Hard code the published release version number into the example package
  • Loading branch information
dangeross authored Oct 19, 2023
2 parents abcb87a + 43bf822 commit 3c602db
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 39 deletions.
26 changes: 23 additions & 3 deletions libs/sdk-react-native/DEVELOPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ yarn global add tslint typescript
```

On first usage you will need to run:
```
```bash
make init
```

Expand All @@ -36,8 +36,7 @@ make react-native-codegen
## Building the bindings

Then to build and copy the Kotlin and Swift bindings into the React Native plugin:

```
```bash
make all
```

Expand Down Expand Up @@ -68,3 +67,24 @@ To use the locally built bindings instead of integrating them remotely:
Reinstall the dependencies in the example project and run it.
It will now use the locally built bindings.

## Testing with the example app

To test locally built bindings in the example app, the npm dependencies need to be updated to use the local package.
In `example/package.json` replace the current version with `file:../`:
```json
"@breeztech/react-native-breez-sdk": "file:../",
```

Run the npm/yarn install to download dependences for both the react-native-breez-sdk package and the example app:
```bash
yarn bootstrap
```

Finally in `example/` start either the iOS or Android app:
```bash
yarn android
```
or for iOS:
```bash
yarn ios
```
6 changes: 5 additions & 1 deletion libs/sdk-react-native/PUBLISHING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ make all
>* ios/libs/libbreez_sdk_core.a
### Publish
When publishing, make sure the version number in `package.json` is updated. Then login to npm:
When publishing, make sure the following are updated:
- Update the version number in `package.json`.
- Set the published version of `@breeztech/react-native-breez-sdk` in `example/package.json`.

Then login to npm:
```
npm login --@scope=@breeztech
```
Expand Down
37 changes: 21 additions & 16 deletions libs/sdk-react-native/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ The Breez SDK provides the following services:

## Installation

```console
$ npm install @breeztech/react-native-breez-sdk
```bash
npm install @breeztech/react-native-breez-sdk
```
or

```console
$ yarn add @breeztech/react-native-breez-sdk
```bash
yarn add @breeztech/react-native-breez-sdk
```

### Important fix for React Native versions below 0.71.0
Expand All @@ -31,7 +31,7 @@ If your project uses a React Native version less < 0.71.0, and you want to build

To fix this you need to disambiguate which file to use by adding the following snippet to your app's `android/app/build.gradle`:

``` gradle
```gradle
android {
// ...
packagingOptions {
Expand All @@ -55,8 +55,10 @@ Please contact [[email protected]](mailto:[email protected]?subjec
```ts
import React, { useEffect } from "react"
import {
BreezEvent,
defaultConfig,
EnvironmentType,
EnvironmentType,
NodeConfigVariant,
sendPayment,
connect
} from "@breeztech/react-native-breez-sdk";
Expand All @@ -65,17 +67,20 @@ import BuildConfig from "react-native-build-config"
const App = () => (
...

const onEvent = (breezEvent: BreezEvent) => {
console.log(`${JSON.stringify(breezEvent)}`)
}

const payInvoice = async (bolt11: string, sats?: number) => {
// Pay invoice
const payment = await sendPayment(bolt11, sats)
}

useEffect(() => {
const asyncFn = async () => {

// create the specific node configuration
// Create the specific node configuration
const nodeConfig = {
type: "greenlight",
type: NodeConfigVariant.GREENLIGHT,
config: {
partnerCredentials: {
deviceKey: null,
Expand All @@ -88,7 +93,7 @@ const App = () => (
const config = await defaultConfig(EnvironmentType.PRODUCTION, BuildConfig.BREEZ_API_KEY, nodeConfig)

// Connect to the Breez SDK make it ready to use
await connect(config, seed)
await connect(config, seed, onEvent)
}

asyncFn()
Expand All @@ -103,14 +108,14 @@ export default App
## Example

In the `example` folder of the [Breez SDK repository](https://github.com/breez/breez-sdk/tree/main/libs/sdk-react-native/example) you will find a basic application for using Breez SDK. Change directory into the folder and install the dependencies:
```console
$ yarn
```bash
yarn
```
Then to run on android:
```console
$ yarn android
```bash
yarn android
```
or for iOS:
```console
$ yarn pods && yarn ios
```bash
yarn pods && yarn ios
```
3 changes: 2 additions & 1 deletion libs/sdk-react-native/example/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
lspInfo,
listFiatCurrencies,
mnemonicToSeed,
NodeConfigVariant,
nodeInfo,
openChannelFee,
receivePayment,
Expand Down Expand Up @@ -81,7 +82,7 @@ const App = () => {
addLine("mnemonicToSeed", obfuscateString(JSON.stringify(seed)))

const nodeConfig = {
type: "greenlight",
type: NodeConfigVariant.GREENLIGHT,
config: {}
}

Expand Down
29 changes: 12 additions & 17 deletions libs/sdk-react-native/example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,22 @@ or replace `INSERT_YOUR_BREEZ_API_KEY` in the following files:
* `android/app/gradle.properties`
* `ios/Secrets.xconfig`

## Build and Run

### Android
## Build

Run the npm/yarn install to download dependences:
```bash
# In directory sdk-react-native
make android
yarn
```
or
```bash
npm i
```

# In the example directory
cd example
rm -rf node_modules
yarn
## Run

### Android

```bash
yarn android
```

Expand All @@ -35,14 +38,6 @@ yarn android
### iOS

```bash
# In directory sdk-react-native
make ios
yarn

# In the example directory
cd example
rm -rf node_modules
yarn
yarn pods
yarn ios
```
Expand Down
2 changes: 1 addition & 1 deletion libs/sdk-react-native/example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"rebuild": "rm -rf node_modules && yarn && yarn pods"
},
"dependencies": {
"@breeztech/react-native-breez-sdk": "file:../",
"@breeztech/react-native-breez-sdk": "0.2.5",
"@dreson4/react-native-quick-bip39": "^0.0.5",
"react": "18.1.0",
"react-native": "0.70.6",
Expand Down

0 comments on commit 3c602db

Please sign in to comment.