Skip to content

Commit 936d5c4

Browse files
committed
Merge branch 'master' into jwt/master
2 parents 0e8b24c + 1c7b504 commit 936d5c4

52 files changed

Lines changed: 4544 additions & 465 deletions

Some content is hidden

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

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,5 @@ module.exports = {
4848
},
4949
},
5050
],
51+
ignorePatterns: ['coverage/**/*', 'lib/**/*', 'docs/**/*'],
5152
};

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ ios/generated
8585
android/generated
8686

8787
# Iterable
88+
.env.local
8889
.env
8990
.xcode.env.local
9091
coverage/

CHANGELOG.md

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,47 @@
1-
## 2.1.0-beta.1
1+
## 2.2.0
22

3-
## Fixes
4-
- Add Temporary fix for circular paths, which break expo ([9c09743](https://github.com/Iterable/react-native-sdk/commit/9c09743))
3+
### Updates
4+
- Updated Android SDK version to [3.6.2](https://github.com/Iterable/iterable-android-sdk/releases/tag/3.6.2)
5+
- Updated iOS SDK version to [6.6.3](https://github.com/Iterable/swift-sdk/releases/tag/6.6.3)
6+
- Added JWT Capabilities:
7+
- Added `Iterable.authhManager`, which manages the authentication flow
8+
- Added `IterableRetryBackoff` and `IterableAuthFailureReason` enums
9+
- Added `onJwtError` and `retryPolicy` for control over JWT flow
10+
- Moved all native calls to `IterableApi.ts`
11+
- Added JWT example to our example app
12+
- Changed `onJWTError` to `onJwtError`
13+
- Changed `IterableRetryBackoff` enum keys to be lowercase for consistency
14+
across application
15+
- [SDK-149] Added logout functionality
516

6-
## 2.1.0-beta.0
17+
### Fixes
18+
- Created a standalone `IterableLogger` to avoid circular dependencies
19+
- [SDK-151] Fixed "cannot read property authtoken of undefined" error
20+
- Fixed Android `retryInterval` not being updated on re-initialization.
721

22+
## 2.1.0
823
### Updates
24+
- SDK is now compatible with both New Architecture and Legacy Architecture. Fix
25+
for #691, #602, #563.
26+
27+
### Fixes
28+
- Dependencies update
929
- Update SDK so that it has full support for [React Native New Architecture](https://reactnative.dev/architecture/landing-page)
30+
- Add Temporary fix for circular paths, which break expo ([9c09743](https://github.com/Iterable/react-native-sdk/commit/9c09743))
1031

1132
### Chores
1233
- Update dependencies for React Navigation and related packages ([95053bb](https://github.com/Iterable/react-native-sdk/commit/95053bb))
1334

35+
## 2.0.4
36+
37+
### Updates
38+
- Added API documentation via Netlify([1087275](https://github.com/Iterable/react-native-sdk/commit/1087275))
39+
- Removed dependency on `react-native-vector-icons`, per issues
40+
[#513](https://github.com/Iterable/react-native-sdk/issues/513),
41+
[#683](https://github.com/Iterable/react-native-sdk/issues/683) and
42+
[#675](https://github.com/Iterable/react-native-sdk/issues/675)
43+
([6ece6e0](https://github.com/Iterable/react-native-sdk/commit/6ece6e0))
44+
- Updated dependencies
1445

1546
## 2.0.3
1647

Iterable-React-Native-SDK.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Pod::Spec.new do |s|
1717
s.private_header_files = "ios/**/*.h"
1818

1919
# Load Iterables iOS SDK as a dependency
20-
s.dependency "Iterable-iOS-SDK", "6.6.1"
20+
s.dependency "Iterable-iOS-SDK", "6.6.3"
2121

2222
# Basic Swift support
2323
s.pod_target_xcconfig = {

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ Iterable's React Native SDK relies on:
4444
_UI Components require additional peer dependencies_
4545
- [React Navigation 6+](https://github.com/react-navigation/react-navigation)
4646
- [React Native Safe Area Context 4+](https://github.com/th3rdwave/react-native-safe-area-context)
47-
- [React Native Vector Icons 10+](https://github.com/oblador/react-native-vector-icons)
4847
- [React Native WebView 13+](https://github.com/react-native-webview/react-native-webview)
4948

5049
- **iOS**
@@ -120,13 +119,13 @@ For quick reference, the following table lists the versions of the [Android SDK]
120119
121120
| RN SDK Version | Android SDK Version | iOS SDK Version |
122121
| --------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | --------------- |
123-
| [2.1.0-beta.0](https://www.npmjs.com/package/@iterable/react-native-sdk/v/2.1.0-beta.0) | [3.5.2](https://github.com/Iterable/iterable-android-sdk/releases/tag/3.5.2) | [6.5.4](https://github.com/Iterable/swift-sdk/releases/tag/6.5.4)
122+
| [2.2.0](https://www.npmjs.com/package/@iterable/react-native-sdk/v/2.2.0) | [3.6.2](https://github.com/Iterable/iterable-android-sdk/releases/tag/3.6.2) | [6.6.3](https://github.com/Iterable/swift-sdk/releases/tag/6.6.3)
123+
| [2.1.0](https://www.npmjs.com/package/@iterable/react-native-sdk/v/2.1.0) | [3.5.2](https://github.com/Iterable/iterable-android-sdk/releases/tag/3.5.2) | [6.5.4](https://github.com/Iterable/swift-sdk/releases/tag/6.5.4)
124+
| [2.0.4](https://www.npmjs.com/package/@iterable/react-native-sdk/v/2.0.4) | [3.5.2](https://github.com/Iterable/iterable-android-sdk/releases/tag/3.5.2) | [6.5.4](https://github.com/Iterable/swift-sdk/releases/tag/6.5.4)
124125
| [2.0.3](https://www.npmjs.com/package/@iterable/react-native-sdk/v/2.0.3) | [3.5.2](https://github.com/Iterable/iterable-android-sdk/releases/tag/3.5.2) | [6.5.4](https://github.com/Iterable/swift-sdk/releases/tag/6.5.4)
125126
| [2.0.2](https://www.npmjs.com/package/@iterable/react-native-sdk/v/2.0.2) | [3.5.2](https://github.com/Iterable/iterable-android-sdk/releases/tag/3.5.2) | [6.5.4](https://github.com/Iterable/swift-sdk/releases/tag/6.5.4)
126127
| [2.0.1](https://www.npmjs.com/package/@iterable/react-native-sdk/v/2.0.1) | [3.5.2](https://github.com/Iterable/iterable-android-sdk/releases/tag/3.5.2) | [6.5.4](https://github.com/Iterable/swift-sdk/releases/tag/6.5.4)
127128
| [2.0.0](https://www.npmjs.com/package/@iterable/react-native-sdk/v/2.0.0) | [3.5.2](https://github.com/Iterable/iterable-android-sdk/releases/tag/3.5.2) | [6.5.4](https://github.com/Iterable/swift-sdk/releases/tag/6.5.4)
128-
| [2.0.0-beta.1](https://www.npmjs.com/package/@iterable/react-native-sdk/v/2.0.0-beta.1) | [3.5.2](https://github.com/Iterable/iterable-android-sdk/releases/tag/3.5.2) | [6.5.4](https://github.com/Iterable/swift-sdk/releases/tag/6.5.4)
129-
| [2.0.0-beta](https://www.npmjs.com/package/@iterable/react-native-sdk/v/2.0.0-beta) | [3.5.2](https://github.com/Iterable/iterable-android-sdk/releases/tag/3.5.2) | [6.5.4](https://github.com/Iterable/swift-sdk/releases/tag/6.5.4)
130129
| [1.3.21](https://www.npmjs.com/package/@iterable/react-native-sdk/v/1.3.20) | [3.5.2](https://github.com/Iterable/iterable-android-sdk/releases/tag/3.5.2) | [6.5.4](https://github.com/Iterable/swift-sdk/releases/tag/6.5.4)
131130
| [1.3.20](https://www.npmjs.com/package/@iterable/react-native-sdk/v/1.3.20) | [3.5.2](https://github.com/Iterable/iterable-android-sdk/releases/tag/3.5.2) | [6.5.4](https://github.com/Iterable/swift-sdk/releases/tag/6.5.4)
132131
| [1.3.19](https://www.npmjs.com/package/@iterable/react-native-sdk/v/1.3.19) | [3.5.2](https://github.com/Iterable/iterable-android-sdk/releases/tag/3.5.2) | [6.5.3](https://github.com/Iterable/swift-sdk/releases/tag/6.5.3)

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def kotlin_version = getExtOrDefault("kotlinVersion")
105105
dependencies {
106106
implementation "com.facebook.react:react-android"
107107
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
108-
api "com.iterable:iterableapi:3.6.1"
108+
api "com.iterable:iterableapi:3.6.2"
109109
// api project(":iterableapi") // links to local android SDK repo rather than by release
110110
}
111111

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

Lines changed: 65 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import com.iterable.iterableapi.IterableApi;
2727
import com.iterable.iterableapi.IterableAttributionInfo;
2828
import com.iterable.iterableapi.IterableAuthHandler;
29+
import com.iterable.iterableapi.IterableAuthManager;
2930
import com.iterable.iterableapi.IterableConfig;
3031
import com.iterable.iterableapi.IterableCustomActionHandler;
3132
// import com.iterable.iterableapi.IterableEmbeddedManager;
@@ -98,7 +99,40 @@ public void initializeWithApiKey(String apiKey, ReadableMap configReadableMap, S
9899
configBuilder.setEnableEmbeddedMessaging(configReadableMap.getBoolean("enableEmbeddedMessaging"));
99100
}
100101

101-
IterableApi.initialize(reactContext, apiKey, configBuilder.build());
102+
if (configReadableMap.hasKey("enableEmbeddedMessaging")) {
103+
configBuilder.setEnableEmbeddedMessaging(configReadableMap.getBoolean("enableEmbeddedMessaging"));
104+
}
105+
106+
IterableConfig config = configBuilder.build();
107+
IterableApi.initialize(reactContext, apiKey, config);
108+
109+
// Update retry policy on existing authManager if it was already created
110+
// This fixes the issue where retryInterval is not respected after
111+
// re-initialization
112+
// TODO [SDK-197]: Fix the root cause of this issue, instead of this hack
113+
try {
114+
// Use reflection to access package-private fields and methods
115+
java.lang.reflect.Field configRetryPolicyField = config.getClass().getDeclaredField("retryPolicy");
116+
configRetryPolicyField.setAccessible(true);
117+
Object retryPolicy = configRetryPolicyField.get(config);
118+
119+
if (retryPolicy != null) {
120+
java.lang.reflect.Method getAuthManagerMethod = IterableApi.getInstance().getClass().getDeclaredMethod("getAuthManager");
121+
getAuthManagerMethod.setAccessible(true);
122+
IterableAuthManager authManager = (IterableAuthManager) getAuthManagerMethod.invoke(IterableApi.getInstance());
123+
124+
if (authManager != null) {
125+
// Update the retry policy field on the authManager
126+
java.lang.reflect.Field authRetryPolicyField = authManager.getClass().getDeclaredField("authRetryPolicy");
127+
authRetryPolicyField.setAccessible(true);
128+
authRetryPolicyField.set(authManager, retryPolicy);
129+
IterableLogger.d(TAG, "Updated retry policy on existing authManager");
130+
}
131+
}
132+
} catch (Exception e) {
133+
IterableLogger.e(TAG, "Failed to update retry policy: " + e.getMessage());
134+
}
135+
102136
IterableApi.getInstance().setDeviceAttribute("reactNativeSDKVersion", version);
103137

104138
IterableApi.getInstance().getInAppManager().addListener(this);
@@ -137,7 +171,36 @@ public void initialize2WithApiKey(String apiKey, ReadableMap configReadableMap,
137171
// override in the Android SDK. Check with @Ayyanchira and @evantk91 to
138172
// see what the best approach is.
139173

140-
IterableApi.initialize(reactContext, apiKey, configBuilder.build());
174+
IterableConfig config = configBuilder.build();
175+
IterableApi.initialize(reactContext, apiKey, config);
176+
177+
// Update retry policy on existing authManager if it was already created
178+
// This fixes the issue where retryInterval is not respected after
179+
// re-initialization
180+
// TODO [SDK-197]: Fix the root cause of this issue, instead of this hack
181+
try {
182+
// Use reflection to access package-private fields and methods
183+
java.lang.reflect.Field configRetryPolicyField = config.getClass().getDeclaredField("retryPolicy");
184+
configRetryPolicyField.setAccessible(true);
185+
Object retryPolicy = configRetryPolicyField.get(config);
186+
187+
if (retryPolicy != null) {
188+
java.lang.reflect.Method getAuthManagerMethod = IterableApi.getInstance().getClass().getDeclaredMethod("getAuthManager");
189+
getAuthManagerMethod.setAccessible(true);
190+
IterableAuthManager authManager = (IterableAuthManager) getAuthManagerMethod.invoke(IterableApi.getInstance());
191+
192+
if (authManager != null) {
193+
// Update the retry policy field on the authManager
194+
java.lang.reflect.Field authRetryPolicyField = authManager.getClass().getDeclaredField("authRetryPolicy");
195+
authRetryPolicyField.setAccessible(true);
196+
authRetryPolicyField.set(authManager, retryPolicy);
197+
IterableLogger.d(TAG, "Updated retry policy on existing authManager");
198+
}
199+
}
200+
} catch (Exception e) {
201+
IterableLogger.e(TAG, "Failed to update retry policy: " + e.getMessage());
202+
}
203+
141204
IterableApi.getInstance().setDeviceAttribute("reactNativeSDKVersion", version);
142205

143206
IterableApi.getInstance().getInAppManager().addListener(this);
@@ -616,11 +679,6 @@ public void onTokenRegistrationSuccessful(String authToken) {
616679
sendEvent(EventName.handleAuthSuccessCalled.name(), null);
617680
}
618681

619-
public void onTokenRegistrationFailed(Throwable object) {
620-
IterableLogger.v(TAG, "Failed to set authToken");
621-
sendEvent(EventName.handleAuthFailureCalled.name(), null);
622-
}
623-
624682
public void addListener(String eventName) {
625683
// Keep: Required for RN built in Event Emitter Calls.
626684
}

example/.env.example

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,19 @@
99
# 4. Fill in the following fields:
1010
# - Name: A descriptive name for the API key
1111
# - Type: Mobile
12-
# - JWT authentication: Leave **unchecked** (IMPORTANT)
12+
# - JWT authentication: Whether or not you want to use JWT
1313
# 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
14+
# 6. Copy the generated API key and replace the placeholder text next to
15+
# `ITBL_API_KEY=` with the copied API key
16+
# 7. If you chose to enable JWT authentication, copy the JWT secret and and
17+
# replace the placeholder text next to `ITBL_JWT_SECRET=` with the copied
18+
# JWT secret
1619
ITBL_API_KEY=replace_this_with_your_iterable_api_key
20+
# Your JWT Secret, created when making your API key (see above)
21+
ITBL_JWT_SECRET=replace_this_with_your_jwt_secret
22+
# Is your api token JWT Enabled?
23+
# Must be set to 'true' to enable JWT authentication
24+
ITBL_IS_JWT_ENABLED=true
1725

1826
# Your Iterable user ID or email address
19-
ITBL_ID=replace_this_with_your_user_id_or_email
27+
ITBL_ID=replace_this_with_your_user_id_or_email

example/README.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ _example app directory_. To do so, run the following:
2323

2424
```bash
2525
cd ios
26-
pod install
26+
bundle install
27+
bundle exec pod install
2728
```
2829

2930
Once this is done, `cd` back into the _example app directory_:
@@ -40,12 +41,18 @@ In it, you will find:
4041

4142
```shell
4243
ITBL_API_KEY=replace_this_with_your_iterable_api_key
44+
ITBL_JWT_SECRET=replace_this_with_your_jwt_secret
45+
ITBL_IS_JWT_ENABLED=true
4346
ITBL_ID=replace_this_with_your_user_id_or_email
4447
```
4548

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+
- Replace `replace_this_with_your_iterable_api_key` with your **_mobile_
50+
Iterable API key**
51+
- Replace `replace_this_with_your_jwt_secret` with your **JWT Secret** (if you
52+
have a JWT-enabled API key)
53+
- Set `ITBL_IS_JWT_ENABLED` to true if you have a JWT-enabled key, and false if you do not.
54+
- Replace `replace_this_with_your_user_id_or_email` with the **email or user
55+
id** that you use to log into Iterable.
4956

5057
Follow the steps below if you do not have a mobile Iterable API key.
5158

@@ -54,12 +61,12 @@ To add an API key, do the following:
5461
1. Sign into your Iterable account
5562
2. Go to [Integrations > API Keys](https://app.iterable.com/settings/apiKeys)
5663
3. Click "New API Key" in the top right corner
57-
4. Fill in the followsing fields:
64+
4. Fill in the following fields:
5865
- Name: A descriptive name for the API key
5966
- Type: Mobile
60-
- JWT authentication: Leave **unchecked** (IMPORTANT)
67+
- JWT authentication: Check to enable JWT authentication. If enabled, will need to create a [JWT generator](https://support.iterable.com/hc/en-us/articles/360050801231-JWT-Enabled-API-Keys#sample-python-code-for-jwt-generation) to generate the JWT token.
6168
5. Click "Create API Key"
62-
6. Copy the generated API key
69+
6. Copy the generated API key and JWT secret into your _.env_ file
6370

6471

6572
## Step 3: Start the Metro Server

example/android/app/build.gradle

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

0 commit comments

Comments
 (0)