|
| 1 | +# branch.json configuration file (optional) |
| 2 | + |
| 3 | +Certain Branch configuration options may be controlled using a JSON configuration file |
| 4 | +in a React Native app project. This feature is rapidly evolving. Support will be added |
| 5 | +for further parameters and custom product flavors (Android) and build schemes (iOS). |
| 6 | +Watch this space for changes. |
| 7 | + |
| 8 | +Starting in release 2.0.0-beta.7, if `branch.json` is present in the app bundle, the |
| 9 | +react-native-branch SDK will use it to set certain options. This is useful for supporting |
| 10 | +certain methods in the native SDKs that must be called before the native SDK initializes. |
| 11 | + |
| 12 | +## Add the files to your project |
| 13 | + |
| 14 | +Be sure to commit `branch.json` and `branch.debug.json` to source control after adding |
| 15 | +them to your project. |
| 16 | + |
| 17 | +### Using react-native link |
| 18 | + |
| 19 | +If `branch.json` or `branch.debug.json` exists in a React Native application project |
| 20 | +using react-native-branch, they will be added to the native projects when `react-native link` |
| 21 | +is run. For example: |
| 22 | + |
| 23 | +```bash |
| 24 | + |
| 25 | +cp node_modules/react-native-branch/branch.example.json branch.json |
| 26 | +react-native link react-native-branch |
| 27 | +``` |
| 28 | + |
| 29 | +#### Projects that already use react-native-branch |
| 30 | + |
| 31 | +Run `react-native unlink react-native-branch` first. For example: |
| 32 | + |
| 33 | +```bash |
| 34 | +react-native unlink react-native-branch |
| 35 | +cp node_modules/react-native-branch/branch.example.json branch.json |
| 36 | +react-native link react-native-branch |
| 37 | +``` |
| 38 | + |
| 39 | +### Manual integration without react-native link |
| 40 | + |
| 41 | +#### Android |
| 42 | + |
| 43 | +Put your `branch.json` file in `app/src/main/assets/branch.json`. |
| 44 | + |
| 45 | +#### iOS |
| 46 | + |
| 47 | +Add `branch.json` to your Xcode project using File > Add Files to "MyProject.xcodeproj". |
| 48 | +Also add it to the Copy Bundle Resources build phase for each application target in |
| 49 | +the project that uses the Branch SDK. |
| 50 | + |
| 51 | +## Configurations for debug and release builds |
| 52 | + |
| 53 | +It is possible to include different versions of the configuration for debug and release |
| 54 | +builds. |
| 55 | + |
| 56 | +### Using react-native link |
| 57 | + |
| 58 | +Optionally add both `branch.json` and `branch.debug.json` to the root of your app |
| 59 | +project and run `react-native link react-native-branch` (after running `react-native unlink react-native-branch` first if the module is already integrated). |
| 60 | + |
| 61 | +### Android |
| 62 | + |
| 63 | +If `app/src/debug/assets/branch.json` exists, that configuration will be used for |
| 64 | +debug builds instead of `app/src/main/assets/branch.json`. |
| 65 | + |
| 66 | +### iOS |
| 67 | + |
| 68 | +Add `branch.debug.json` to your project and the Copy Bundle Resources build phase(s) |
| 69 | +as discussed above. If this file is present, it will be used in debug builds instead |
| 70 | +of `branch.json`. |
| 71 | + |
| 72 | +## Contents |
| 73 | + |
| 74 | +|key|description|type| |
| 75 | +|---|---|---| |
| 76 | +|debugMode|If true, `setDebug` will be called in the native SDK, enabling testing of install events.|Boolean| |
| 77 | + |
| 78 | +## Example |
| 79 | + |
| 80 | +See [branch.example.json](https://github.com/BranchMetrics/react-native-branch-deep-linking/blob/master/branch.example.json) in the root of this repo. |
| 81 | + |
| 82 | +```json |
| 83 | +{ |
| 84 | + "debugMode": true |
| 85 | +} |
| 86 | +``` |
0 commit comments