|
1 | | -This is a new [**React Native**](https://reactnative.dev) project, bootstrapped using [`@react-native-community/cli`](https://github.com/react-native-community/cli). |
| 1 | +This is the Iterable React Native Example App, bootstrapped using |
| 2 | +[`@react-native-community/cli`](https://github.com/react-native-community/cli). |
| 3 | + |
| 4 | +Use this to understand how you can use Iterables React Native SDK in your own |
| 5 | +React Native application. |
2 | 6 |
|
3 | 7 | # Getting Started |
4 | 8 |
|
5 | | ->**Note**: Make sure you have completed the [React Native - Environment Setup](https://reactnative.dev/docs/environment-setup) instructions till "Creating a new application" step, before proceeding. |
| 9 | +>**Note**: Make sure you have completed the [React Native - Environment |
| 10 | +>Setup](https://reactnative.dev/docs/set-up-your-environment) instructions till |
| 11 | +>"Creating a new application" step, before proceeding. |
| 12 | +
|
| 13 | +## Step 1: Install dependencies |
| 14 | +To install the app dependencies, run the following command from the |
| 15 | +_example app directory_ (the directory in which this document resides): |
| 16 | + |
| 17 | +```bash |
| 18 | +yarn install |
| 19 | +``` |
| 20 | + |
| 21 | +Once this is done, you will need to install the pods in the _ios_ folder in the |
| 22 | +_example app directory_. To do so, run the following: |
| 23 | + |
| 24 | +```bash |
| 25 | +cd ios |
| 26 | +pod install |
| 27 | +``` |
| 28 | + |
| 29 | +Once this is done, `cd` back into the _example app directory_: |
| 30 | + |
| 31 | +```bash |
| 32 | +cd .. |
| 33 | +``` |
| 34 | + |
| 35 | +## Step 2: Add your environment variables |
| 36 | +In the _example app directory_, there is a file called **.env.example**. Make a |
| 37 | +copy of this file, name it **.env** and place it in the exampe app directory. |
| 38 | + |
| 39 | +In it, you will find: |
| 40 | + |
| 41 | +```shell |
| 42 | +ITBL_API_KEY=replace_this_with_your_iterable_api_key |
| 43 | +ITBL_ID=replace_this_with_your_user_id_or_email |
| 44 | +``` |
6 | 45 |
|
7 | | -## Step 1: Start the Metro Server |
| 46 | +Replace `replace_this_with_your_iterable_api_key` with your _mobile_ Iterable API key, |
| 47 | +and replace `replace_this_with_your_user_id_or_email` with the email or user id |
| 48 | +that you use to log into Iterable. |
| 49 | + |
| 50 | +Follow the steps below if you do not have a mobile Iterable API key. |
| 51 | + |
| 52 | +### Adding an API Key |
| 53 | +To add an API key, do the following: |
| 54 | + 1. Sign into your Iterable account |
| 55 | + 2. Go to [Integrations > API Keys](https://app.iterable.com/settings/apiKeys) |
| 56 | + 3. Click "New API Key" in the top right corner |
| 57 | + 4. Fill in the followsing fields: |
| 58 | + - Name: A descriptive name for the API key |
| 59 | + - Type: Mobile |
| 60 | + - JWT authentication: Leave **unchecked** (IMPORTANT) |
| 61 | + 5. Click "Create API Key" |
| 62 | + 6. Copy the generated API key |
| 63 | + |
| 64 | + |
| 65 | +## Step 3: Start the Metro Server |
8 | 66 |
|
9 | 67 | First, you will need to start **Metro**, the JavaScript _bundler_ that ships _with_ React Native. |
10 | 68 |
|
11 | 69 | To start Metro, run the following command from the _root_ of your React Native project: |
12 | 70 |
|
13 | 71 | ```bash |
14 | | -# using npm |
15 | | -npm start |
16 | | - |
17 | | -# OR using Yarn |
18 | 72 | yarn start |
19 | 73 | ``` |
20 | 74 |
|
21 | | -## Step 2: Start your Application |
| 75 | +## Step 4: Start your Application |
22 | 76 |
|
23 | 77 | Let Metro Bundler run in its _own_ terminal. Open a _new_ terminal from the _root_ of your React Native project. Run the following command to start your _Android_ or _iOS_ app: |
24 | 78 |
|
25 | 79 | ### For Android |
26 | 80 |
|
27 | 81 | ```bash |
28 | | -# using npm |
29 | | -npm run android |
30 | | - |
31 | | -# OR using Yarn |
32 | 82 | yarn android |
33 | 83 | ``` |
34 | 84 |
|
35 | 85 | ### For iOS |
36 | 86 |
|
37 | 87 | ```bash |
38 | | -# using npm |
39 | | -npm run ios |
40 | | - |
41 | | -# OR using Yarn |
42 | 88 | yarn ios |
43 | 89 | ``` |
44 | 90 |
|
45 | 91 | If everything is set up _correctly_, you should see your new app running in your _Android Emulator_ or _iOS Simulator_ shortly provided you have set up your emulator/simulator correctly. |
46 | 92 |
|
47 | 93 | This is one way to run your app — you can also run it directly from within Android Studio and Xcode respectively. |
48 | 94 |
|
49 | | -## Step 3: Modifying your App |
50 | | - |
51 | | -Now that you have successfully run the app, let's modify it. |
52 | 95 |
|
53 | | -1. Open `App.tsx` in your text editor of choice and edit some lines. |
54 | | -2. For **Android**: Press the <kbd>R</kbd> key twice or select **"Reload"** from the **Developer Menu** (<kbd>Ctrl</kbd> + <kbd>M</kbd> (on Window and Linux) or <kbd>Cmd ⌘</kbd> + <kbd>M</kbd> (on macOS)) to see your changes! |
| 96 | +## Congratulations! :tada: |
55 | 97 |
|
56 | | - For **iOS**: Hit <kbd>Cmd ⌘</kbd> + <kbd>R</kbd> in your iOS Simulator to reload the app and see your changes! |
| 98 | +You've successfully run the Iterable Example App. :partying_face: |
57 | 99 |
|
58 | | -## Congratulations! :tada: |
59 | 100 |
|
60 | | -You've successfully run and modified your React Native App. :partying_face: |
| 101 | +# Troubleshooting |
61 | 102 |
|
62 | | -### Now what? |
| 103 | +## Error: `Could not find gem 'cocoapods (>= 1.13, != 1.15.0, != 1.15.1)' in locally installed gems` |
63 | 104 |
|
64 | | -- If you want to add this new React Native code to an existing application, check out the [Integration guide](https://reactnative.dev/docs/integration-with-existing-apps). |
65 | | -- If you're curious to learn more about React Native, check out the [Introduction to React Native](https://reactnative.dev/docs/getting-started). |
| 105 | +To fix, run the following in the _example app directory_: |
66 | 106 |
|
67 | | -# Troubleshooting |
| 107 | +```bash |
| 108 | +bundle install |
| 109 | +``` |
68 | 110 |
|
69 | | -If you can't get this to work, see the [Troubleshooting](https://reactnative.dev/docs/troubleshooting) page. |
| 111 | +## Other |
| 112 | +If things are not working and you are stumped as to why, try running the |
| 113 | +following in the _example app directory_: |
70 | 114 |
|
71 | | -# Learn More |
| 115 | +```bash |
| 116 | +npx react-native doctor |
| 117 | +``` |
72 | 118 |
|
73 | | -To learn more about React Native, take a look at the following resources: |
| 119 | +This will give you information about what react native needs in order to run, |
| 120 | +and whether it is accessible to the app. |
74 | 121 |
|
75 | | -- [React Native Website](https://reactnative.dev) - learn more about React Native. |
76 | | -- [Getting Started](https://reactnative.dev/docs/environment-setup) - an **overview** of React Native and how setup your environment. |
77 | | -- [Learn the Basics](https://reactnative.dev/docs/getting-started) - a **guided tour** of the React Native **basics**. |
78 | | -- [Blog](https://reactnative.dev/blog) - read the latest official React Native **Blog** posts. |
79 | | -- [`@facebook/react-native`](https://github.com/facebook/react-native) - the Open Source; GitHub **repository** for React Native. |
| 122 | +Take a look at the OS you are trying to run. Make sure that everything has been |
| 123 | +installed and that the necessary items have been added to your `PATH`. |
0 commit comments