Skip to content

Commit d90369f

Browse files
committed
Update README and environment setup: enhance instructions for API key setup, modify navigation steps, and improve dotenv configuration in Babel
1 parent 0491d27 commit d90369f

File tree

5 files changed

+108
-49
lines changed

5 files changed

+108
-49
lines changed

example/.env.example

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
# - JWT authentication: Leave **unchecked** (IMPORTANT)
1313
# 5. Click "Create API Key"
1414
# 6. Copy the generated API key
15-
# 7. Replace the placeholder text next to `ITBL_API_KEY=` with the copied API
16-
# key
15+
# 7. Replace the placeholder text next to `ITBL_API_KEY=` with the copied API key
1716
ITBL_API_KEY=replace_this_with_your_iterable_api_key
1817

1918
# Your Iterable user ID or email address

example/README.md

Lines changed: 80 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,123 @@
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.
26

37
# Getting Started
48

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 start
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+
```
45+
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+
664

7-
## Step 1: Start the Metro Server
65+
## Step 3: Start the Metro Server
866

967
First, you will need to start **Metro**, the JavaScript _bundler_ that ships _with_ React Native.
1068

1169
To start Metro, run the following command from the _root_ of your React Native project:
1270

1371
```bash
14-
# using npm
15-
npm start
16-
17-
# OR using Yarn
1872
yarn start
1973
```
2074

21-
## Step 2: Start your Application
75+
## Step 4: Start your Application
2276

2377
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:
2478

2579
### For Android
2680

2781
```bash
28-
# using npm
29-
npm run android
30-
31-
# OR using Yarn
3282
yarn android
3383
```
3484

3585
### For iOS
3686

3787
```bash
38-
# using npm
39-
npm run ios
40-
41-
# OR using Yarn
4288
yarn ios
4389
```
4490

4591
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.
4692

4793
This is one way to run your app — you can also run it directly from within Android Studio and Xcode respectively.
4894

49-
## Step 3: Modifying your App
50-
51-
Now that you have successfully run the app, let's modify it.
5295

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:
5597

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:
5799

58-
## Congratulations! :tada:
59100

60-
You've successfully run and modified your React Native App. :partying_face:
101+
# Troubleshooting
61102

62-
### Now what?
103+
## Error: `Could not find gem 'cocoapods (>= 1.13, != 1.15.0, != 1.15.1)' in locally installed gems`
63104

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_:
66106

67-
# Troubleshooting
107+
```bash
108+
bundle install
109+
```
68110

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_:
70114

71-
# Learn More
115+
```bash
116+
npx react-native doctor
117+
```
72118

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.
74121

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`.

example/babel.config.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,23 @@ module.exports = function (api) {
1010
return getConfig(
1111
{
1212
presets: ['module:@react-native/babel-preset'],
13-
plugins: ['module:react-native-dotenv'],
13+
plugins: [
14+
[
15+
'module:react-native-dotenv',
16+
{
17+
envName: 'APP_ENV',
18+
moduleName: '@env',
19+
path: '.env',
20+
blocklist: null,
21+
allowlist: null,
22+
blacklist: null, // DEPRECATED
23+
whitelist: null, // DEPRECATED
24+
safe: false,
25+
allowUndefined: true,
26+
verbose: false,
27+
},
28+
],
29+
],
1430
},
1531
{ root, pkg },
1632
);

example/ios/Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1896,7 +1896,7 @@ SPEC CHECKSUMS:
18961896
RNScreens: 19719a9c326e925498ac3b2d35c4e50fe87afc06
18971897
RNVectorIcons: 6382277afab3c54658e9d555ee0faa7a37827136
18981898
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
1899-
Yoga: 1354c027ab07c7736f99a3bef16172d6f1b12b47
1899+
Yoga: 4ef80d96a5534f0e01b3055f17d1e19a9fc61b63
19001900

19011901
PODFILE CHECKSUM: aab4a30773612c4ffb73be13f5b169b8b156f374
19021902

example/src/hooks/useIterableApp.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
import {
2-
Iterable,
3-
IterableAction,
4-
IterableConfig,
5-
IterableInAppShowResponse,
6-
IterableLogLevel,
7-
} from '@iterable/react-native-sdk';
8-
1+
import type { StackNavigationProp } from '@react-navigation/stack';
92
import {
103
type FunctionComponent,
114
createContext,
@@ -15,7 +8,14 @@ import {
158
} from 'react';
169
import { Alert } from 'react-native';
1710

18-
import type { StackNavigationProp } from '@react-navigation/stack';
11+
import {
12+
Iterable,
13+
IterableAction,
14+
IterableConfig,
15+
IterableInAppShowResponse,
16+
IterableLogLevel,
17+
} from '@iterable/react-native-sdk';
18+
1919
import { Route } from '../constants/routes';
2020
import type { RootStackParamList } from '../types/navigation';
2121

0 commit comments

Comments
 (0)