Skip to content

Commit 38db7c3

Browse files
authored
Merge pull request #590 from Iterable/2.0.0-alpha/MOB-10032-add-login-page
[MOB-10032] Example App: Login page
2 parents 291884c + 5b442a9 commit 38db7c3

File tree

44 files changed

+4502
-99
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+4502
-99
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,7 @@ lib/
8080
# React Native Codegen
8181
ios/generated
8282
android/generated
83+
84+
# Iterable
85+
.env
86+
.xcode.env.local

android/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
buildscript {
22
// Buildscript is evaluated before everything else so we can't use getExtOrDefault
3-
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["ReactNativeSdk_kotlinVersion"]
3+
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["RNIterable_kotlinVersion"]
44

55
repositories {
66
google()
@@ -31,11 +31,11 @@ if (isNewArchitectureEnabled()) {
3131
}
3232

3333
def getExtOrDefault(name) {
34-
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["ReactNativeSdk_" + name]
34+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["RNIterable_" + name]
3535
}
3636

3737
def getExtOrIntegerDefault(name) {
38-
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["ReactNativeSdk_" + name]).toInteger()
38+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["RNIterable_" + name]).toInteger()
3939
}
4040

4141
def supportsNamespace() {

android/gradle.properties

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
ReactNativeSdk_kotlinVersion=1.7.0
2-
ReactNativeSdk_minSdkVersion=21
3-
ReactNativeSdk_targetSdkVersion=31
4-
ReactNativeSdk_compileSdkVersion=31
5-
ReactNativeSdk_ndkversion=21.4.7075529
1+
RNIterable_kotlinVersion=1.7.0
2+
RNIterable_minSdkVersion=21
3+
RNIterable_targetSdkVersion=31
4+
RNIterable_compileSdkVersion=31
5+
RNIterable_ndkversion=21.4.7075529
6+
android.useAndroidX=true
7+
android.enableJetifier=true
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
6+
zipStoreBase=GRADLE_USER_HOME
7+
zipStorePath=wrapper/dists

android/src/main/java/com/iterable/reactnative/RNIterableAPIPackage.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.iterable.reactnative;
22

3+
import java.util.ArrayList;
34
import java.util.Arrays;
45
import java.util.Collections;
56
import java.util.List;
@@ -12,8 +13,13 @@
1213

1314
public class RNIterableAPIPackage implements ReactPackage {
1415
@Override
15-
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
16-
return Arrays.<NativeModule>asList(new RNIterableAPIModule(reactContext));
16+
public List<NativeModule> createNativeModules(
17+
ReactApplicationContext reactContext) {
18+
List<NativeModule> modules = new ArrayList<>();
19+
20+
modules.add(new RNIterableAPIModule(reactContext));
21+
22+
return modules;
1723
}
1824

1925
@Override

example/.env.example

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# This file contains environment variables that are used by the example scripts.
2+
# To use the example scripts, you must first copy this file to `.env` and
3+
# replace the placeholder text with your own values.
4+
5+
# To add an API key, do the following:
6+
# 1. Sign into your Iterable account
7+
# 2. Go to [Integrations > API Keys](https://app.iterable.com/settings/apiKeys)
8+
# 3. Click "New API Key" in the top right corner
9+
# 4. Fill in the following fields:
10+
# - Name: A descriptive name for the API key
11+
# - Type: Mobile
12+
# - JWT authentication: Leave **unchecked** (IMPORTANT)
13+
# 5. Click "Create API Key"
14+
# 6. Copy the generated API key
15+
# 7. Replace the placeholder text next to `ITBL_API_KEY=` with the copied API key
16+
ITBL_API_KEY=replace_this_with_your_iterable_api_key
17+
18+
# Your Iterable user ID or email address
19+
ITBL_ID=replace_this_with_your_user_id_or_email

example/Gemfile.lock

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
CFPropertyList (3.0.7)
5+
base64
6+
nkf
7+
rexml
8+
activesupport (6.1.7.9)
9+
concurrent-ruby (~> 1.0, >= 1.0.2)
10+
i18n (>= 1.6, < 2)
11+
minitest (>= 5.1)
12+
tzinfo (~> 2.0)
13+
zeitwerk (~> 2.3)
14+
addressable (2.8.7)
15+
public_suffix (>= 2.0.2, < 7.0)
16+
algoliasearch (1.27.5)
17+
httpclient (~> 2.8, >= 2.8.3)
18+
json (>= 1.5.1)
19+
atomos (0.1.3)
20+
base64 (0.2.0)
21+
claide (1.1.0)
22+
cocoapods (1.15.2)
23+
addressable (~> 2.8)
24+
claide (>= 1.0.2, < 2.0)
25+
cocoapods-core (= 1.15.2)
26+
cocoapods-deintegrate (>= 1.0.3, < 2.0)
27+
cocoapods-downloader (>= 2.1, < 3.0)
28+
cocoapods-plugins (>= 1.0.0, < 2.0)
29+
cocoapods-search (>= 1.0.0, < 2.0)
30+
cocoapods-trunk (>= 1.6.0, < 2.0)
31+
cocoapods-try (>= 1.1.0, < 2.0)
32+
colored2 (~> 3.1)
33+
escape (~> 0.0.4)
34+
fourflusher (>= 2.3.0, < 3.0)
35+
gh_inspector (~> 1.0)
36+
molinillo (~> 0.8.0)
37+
nap (~> 1.0)
38+
ruby-macho (>= 2.3.0, < 3.0)
39+
xcodeproj (>= 1.23.0, < 2.0)
40+
cocoapods-core (1.15.2)
41+
activesupport (>= 5.0, < 8)
42+
addressable (~> 2.8)
43+
algoliasearch (~> 1.0)
44+
concurrent-ruby (~> 1.1)
45+
fuzzy_match (~> 2.0.4)
46+
nap (~> 1.0)
47+
netrc (~> 0.11)
48+
public_suffix (~> 4.0)
49+
typhoeus (~> 1.0)
50+
cocoapods-deintegrate (1.0.5)
51+
cocoapods-downloader (2.1)
52+
cocoapods-plugins (1.0.0)
53+
nap
54+
cocoapods-search (1.0.1)
55+
cocoapods-trunk (1.6.0)
56+
nap (>= 0.8, < 2.0)
57+
netrc (~> 0.11)
58+
cocoapods-try (1.2.0)
59+
colored2 (3.1.2)
60+
concurrent-ruby (1.3.4)
61+
escape (0.0.4)
62+
ethon (0.16.0)
63+
ffi (>= 1.15.0)
64+
ffi (1.17.0)
65+
fourflusher (2.3.1)
66+
fuzzy_match (2.0.4)
67+
gh_inspector (1.1.3)
68+
httpclient (2.8.3)
69+
i18n (1.14.6)
70+
concurrent-ruby (~> 1.0)
71+
json (2.7.2)
72+
minitest (5.25.1)
73+
molinillo (0.8.0)
74+
nanaimo (0.3.0)
75+
nap (1.1.0)
76+
netrc (0.11.0)
77+
nkf (0.2.0)
78+
public_suffix (4.0.7)
79+
rexml (3.3.8)
80+
ruby-macho (2.5.1)
81+
typhoeus (1.4.1)
82+
ethon (>= 0.9.0)
83+
tzinfo (2.0.6)
84+
concurrent-ruby (~> 1.0)
85+
xcodeproj (1.25.1)
86+
CFPropertyList (>= 2.3.3, < 4.0)
87+
atomos (~> 0.1.3)
88+
claide (>= 1.0.2, < 2.0)
89+
colored2 (~> 3.1)
90+
nanaimo (~> 0.3.0)
91+
rexml (>= 3.3.6, < 4.0)
92+
zeitwerk (2.6.18)
93+
94+
PLATFORMS
95+
ruby
96+
97+
DEPENDENCIES
98+
activesupport (>= 6.1.7.5, != 7.1.0)
99+
cocoapods (>= 1.13, != 1.15.1, != 1.15.0)
100+
101+
RUBY VERSION
102+
ruby 2.6.10p210
103+
104+
BUNDLED WITH
105+
1.17.2

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 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+
```
645

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
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/android/app/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,5 @@ dependencies {
117117
implementation jscFlavor
118118
}
119119
}
120+
121+
apply from: file("../../node_modules/react-native-vector-icons/fonts.gradle")

example/android/app/src/main/java/iterable/reactnativesdk/example/MainActivity.kt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package iterable.reactnativesdk.example
22

3+
import android.os.Bundle
4+
35
import com.facebook.react.ReactActivity
46
import com.facebook.react.ReactActivityDelegate
57
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
@@ -19,4 +21,12 @@ class MainActivity : ReactActivity() {
1921
*/
2022
override fun createReactActivityDelegate(): ReactActivityDelegate =
2123
DefaultReactActivityDelegate(this, mainComponentName, fabricEnabled)
22-
}
24+
25+
/**
26+
* For react-native-screens
27+
* This being in Kotlin **may** cause issues with react-native-screens
28+
*/
29+
override fun onCreate(savedInstanceState: Bundle?) {
30+
super.onCreate(null)
31+
}
32+
}

0 commit comments

Comments
 (0)