Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
135 commits
Select commit Hold shift + click to select a range
7b77235
test: add unit tests for useDeviceOrientation
lposen Oct 3, 2025
94665c5
test: implement unit tests for useDeviceOrientation hook to ensure ac…
lposen Oct 3, 2025
523b638
test: add TODO comments to IterableUtil tests for type verification o…
lposen Oct 3, 2025
fd08ea5
test: add unit tests for IterableEdgeInsets
lposen Oct 3, 2025
51f7df8
test: add unit tests for IterableHtmlInAppContent
lposen Oct 3, 2025
553ee16
test: add mock methods for inbox message retrieval and HTML content g…
lposen Oct 3, 2025
605d28c
test: add unit tests for IterableInAppManager
lposen Oct 3, 2025
fe756ec
Merge branch 'feature/MOB-12159-add-tests-for-useappstatelistener' in…
lposen Oct 6, 2025
01677ca
Merge branch 'master' into feature/MOB-12160-add-tests-for-usedeviceo…
lposen Oct 8, 2025
67a806d
fix: removed comment description that no longer applies
lposen Oct 13, 2025
7f332b4
Merge branch 'master' into feature/MOB-12160-add-tests-for-usedeviceo…
lposen Oct 13, 2025
d9a7b82
test: prettify Iterable test file
lposen Oct 13, 2025
1dbd4e2
Merge branch 'jwt/master' into jwt/MOB-10946-task-2-authfailure-and-r…
lposen Oct 13, 2025
71ac5c4
docs: add better comments to IterableAuthManager
lposen Oct 13, 2025
d95ae90
fix: standardize authentication failure reason representation across …
lposen Oct 13, 2025
e63c0d7
Merge pull request #708 from Iterable/feature/MOB-12160-add-tests-for…
lposen Oct 13, 2025
e417eeb
Merge pull request #709 from Iterable/feature/MOB-12186-add-tests-for…
lposen Oct 13, 2025
5667794
fix: update project.pbxproj to correct file references and improve bu…
lposen Oct 13, 2025
35b74d4
feat: add syncEmbeddedMessages method to ReactIterableAPI and expose …
lposen Oct 13, 2025
0e8b24c
feat: implement getEmbeddedMessages method. not working -- giving ba…
lposen Oct 13, 2025
b31ffd7
Merge branch 'jwt/MOB-10946-task-2-authfailure-and-retrypolicy-ts-cla…
lposen Oct 14, 2025
0587649
Merge branch 'jwt/MOB-10947-task-3-android-retrypolicy-config-at-andr…
lposen Oct 14, 2025
8e5dbac
Merge branch 'master' into MOB-12188-add-tests-for-iterablehtmlinappc…
lposen Oct 14, 2025
b7d6389
fix: add missing commas in IterableHtmlInAppContent test cases for co…
lposen Oct 14, 2025
607a55b
Merge branch 'master' into new-arch/master
lposen Oct 14, 2025
9883a21
Merge branch 'new-arch/master' into jwt/master
lposen Oct 14, 2025
0eedca5
Merge pull request #726 from Iterable/jwt/MOB-10946-task-2-authfailur…
lposen Oct 14, 2025
ed20041
Merge branch 'jwt/master' into jwt/MOB-10947-task-3-android-retrypoli…
lposen Oct 14, 2025
0191b7b
chore: removed onTokenRegistrationFailed method as per PR comment
lposen Oct 14, 2025
70fa36a
feat: implement retry policy configuration in IterableConfig for iOS
lposen Oct 14, 2025
52d5ac4
Merge branch 'jwt/MOB-11032-task-4-ios-bridge-retrypolicy-and-authfai…
lposen Oct 14, 2025
2fa18f8
Merge branch 'jwt/MOB-12231-create-an-iterableapi-class-for-api-calls…
lposen Oct 14, 2025
5fa3361
Merge pull request #727 from Iterable/jwt/MOB-10947-task-3-android-re…
lposen Oct 14, 2025
db24c40
Merge branch 'jwt/master' into jwt/MOB-11032-task-4-ios-bridge-retryp…
lposen Oct 14, 2025
e579386
Merge pull request #728 from Iterable/jwt/MOB-11032-task-4-ios-bridge…
lposen Oct 14, 2025
c9fefd7
Merge branch 'jwt/master' into jwt/MOB-12231-create-an-iterableapi-cl…
lposen Oct 14, 2025
23d719a
test: add tests to IterableApi
lposen Oct 14, 2025
644c510
Merge branch 'jwt/MOB-12231-create-an-iterableapi-class-for-api-calls…
lposen Oct 14, 2025
a693494
docs: enhance IterableLogger documentation with descriptions and exa…
lposen Oct 14, 2025
54f4626
Merge branch 'jwt/MOB-12298-new-improve-logger' of github.com:Iterabl…
lposen Oct 14, 2025
74a6409
feat: add back icon assets for multiple resolutions and platforms
lposen Oct 15, 2025
4308017
refactor: add HeaderBackButton component and integrate it into Iterab…
lposen Oct 15, 2025
2c9a954
refactor: create HeaderBackButton and replace back-arrow
lposen Oct 15, 2025
9bf1178
chore: add prettier-eslint and update dependencies in package.json an…
lposen Oct 15, 2025
0e1bb04
chore: remove unused back icon assets for various resolutions and pla…
lposen Oct 15, 2025
4fe7c80
feat: replace icon references with base64 encoded images
lposen Oct 15, 2025
6ece6e0
chore: remove react-native-vector-icons dependency and related config…
lposen Oct 15, 2025
c1f3dec
test: add comprehensive tests for HeaderBackButton component
lposen Oct 15, 2025
66b122f
Merge pull request #710 from Iterable/feature/MOB-12187-add-tests-for…
lposen Oct 16, 2025
0091a8f
Merge pull request #711 from Iterable/MOB-12188-add-tests-for-iterabl…
lposen Oct 16, 2025
99db035
Merge branch 'master' into new-arch/master
lposen Oct 16, 2025
5517bf7
Update src/inApp/classes/IterableInAppManager.ts
lposen Oct 16, 2025
a2e5177
Merge pull request #737 from Iterable/jwt/MOB-12231-create-an-iterabl…
lposen Oct 16, 2025
42669ff
Merge branch 'new-arch/master' into jwt/master
lposen Oct 16, 2025
6614c24
Merge pull request #760 from Iterable/MOB-12247-remove-dependency-on-…
lposen Oct 16, 2025
7144ab1
chore: update version to 2.0.4 in package.json and itblBuildInfo.ts
lposen Oct 16, 2025
d32bdd2
chore: update CHANGELOG for version 2.0.4
lposen Oct 16, 2025
d274c0f
chore: update CHANGELOG to remove unit tests entry for version 2.0.4
lposen Oct 16, 2025
b37eb9f
Merge pull request #761 from Iterable/MOB-12360-release-2-0-4
lposen Oct 16, 2025
a4bd708
Merge branch 'jwt/master' into jwt/MOB-12298-new-improve-logger
lposen Oct 17, 2025
b082dc9
Merge branch 'master' into feature/MOB-12189-add-tests-to-iterableina…
lposen Oct 17, 2025
c0a2c20
docs: removed a TODO and enhanced documentation for IterableLogger
lposen Oct 17, 2025
169c584
Merge branch 'master' into new-arch/master
lposen Oct 17, 2025
1eb3069
Merge branch 'new-arch/master' into jwt/master
lposen Oct 17, 2025
e06edab
Merge branch 'jwt/master' into jwt/MOB-12298-new-improve-logger
lposen Oct 17, 2025
6828a7a
fix: change default log level from info to debug in IterableConfig
lposen Oct 17, 2025
e2c6148
refactor: update default log level to debug in IterableLogger and rel…
lposen Oct 17, 2025
d695a8b
Merge pull request #739 from Iterable/jwt/MOB-12298-new-improve-logger
lposen Oct 17, 2025
2dcb969
chore: update yarn.lock and enhance example configuration documentation
lposen Oct 21, 2025
1bfa9d5
chore: add .env.local to .gitignore and update example configuration …
lposen Oct 21, 2025
d471800
refactor: small updates to ReactIterable.swift
lposen Oct 21, 2025
6a9972a
feat: implement JWT generation module for React Native in example
lposen Oct 21, 2025
ad48782
chore: remove unused crypto-js and @types/crypto-js dependencies from…
lposen Oct 21, 2025
5df923f
feat: add IterableJwtGenerator and JwtTokenModule for JWT token gener…
lposen Oct 21, 2025
40c4bad
fix: ensure login is called during initialization and improve error h…
lposen Oct 21, 2025
fea6232
refactor: remove commented-out code from IterableJwtGenerator.swift t…
lposen Oct 21, 2025
fd76f08
refactor: remove unnecessary login calls and clean up error handling …
lposen Oct 21, 2025
b663dce
refactor: remove console log statements to streamline IterableAppProv…
lposen Oct 21, 2025
a58be2a
feat: introduce NativeJwtTokenModule for JWT token generation and rem…
lposen Oct 21, 2025
13012d9
refactor: enhance JWT generation methods and update .env.example comm…
lposen Oct 21, 2025
84f7fff
chore: remove font references from Info.plist to streamline configura…
lposen Oct 21, 2025
9038579
Merge pull request #767 from Iterable/jwt/SDK-136-new-jwt-token-gener…
lposen Oct 21, 2025
d7f81c0
chore: update package version to 2.2.0-alpha.0 in package.json and it…
lposen Oct 21, 2025
e7deb3d
chore: update CHANGELOG.md for 2.2.0-alpha.0 release
lposen Oct 21, 2025
e494b19
refactor: add type guard for IterableAuthResponse and simplify promis…
lposen Oct 22, 2025
ca88683
fix: remove node only call
lposen Nov 3, 2025
91937fe
Merge pull request #704 from Iterable/new-arch/master
lposen Nov 3, 2025
2adf8d8
chore(deps): bump tar from 7.5.1 to 7.5.2
dependabot[bot] Nov 3, 2025
2d4e380
chore: update version to 2.1.0 in package.json and itblBuildInfo.ts
lposen Nov 3, 2025
ebf660c
chore: update CHANGELOG for version 2.1.0 with new features and depen…
lposen Nov 3, 2025
c7a0ac8
chore: update CHANGELOG for version 2.1.0 with updates and fixes
lposen Nov 3, 2025
e1d79bb
Merge pull request #773 from Iterable/new-arch/MOB-12216-ga-release
lposen Nov 3, 2025
41b0a52
chore(deps-dev): bump @react-native-community/cli from 18.0.0 to 18.0.1
dependabot[bot] Nov 6, 2025
5103d54
Merge branch 'master' into feature/SDK-151-cannot-read-property-autht…
lposen Nov 10, 2025
b935b46
Merge branch 'master' into jwt/master
lposen Nov 10, 2025
4bcbb18
Merge branch 'jwt/master' into feature/SDK-151-cannot-read-property-a…
lposen Nov 10, 2025
c6548d2
Merge pull request #779 from Iterable/feature/SDK-151-cannot-read-pro…
lposen Nov 10, 2025
cacb0ea
chore: update Iterable-iOS-SDK and Iterable API dependencies to versi…
lposen Nov 10, 2025
b397602
chore: update Iterable-iOS-SDK to 6.6.3 and add @react-native-communi…
lposen Nov 11, 2025
1d74fed
Merge pull request #780 from Iterable/jwt/SDK-181-update-sdk-versions…
lposen Nov 12, 2025
03d7967
fix: remove additional event listeners for auth success and failure i…
lposen Nov 12, 2025
954df65
feat: add logout method to Iterable class and refactor event listener…
lposen Nov 13, 2025
900ee9c
test: add unit tests for Iterable.logout method to verify functionality
lposen Nov 13, 2025
f72f578
fix: correct typo in comment regarding AuthResponse in Iterable class
lposen Nov 14, 2025
b9401df
test: add clarification comment in Iterable.logout test for better un…
lposen Nov 14, 2025
8a66205
Merge pull request #781 from Iterable/jwt/SDK-149-add-logout-function…
lposen Nov 14, 2025
fb680ae
chore: bump version to 2.2.0-alpha.1 in package.json and itblBuildInf…
lposen Nov 14, 2025
95103af
chore: update CHANGELOG.md for version 2.2.0-alpha.1 with recent fixe…
lposen Nov 14, 2025
c6dc370
chore(deps): bump js-yaml from 3.14.1 to 3.14.2
dependabot[bot] Nov 17, 2025
c4bd009
fix: standardize casing of onJwtError in configuration and implementa…
lposen Nov 18, 2025
d304442
fix: standardize enum casing for IterableRetryBackoff and update docu…
lposen Nov 19, 2025
e21df58
chore: update CHANGELOG.md for version 2.1.0 and adjust README.md for…
lposen Nov 19, 2025
6df9e79
fix: correct enum casing for IterableRetryBackoff and update usage in…
lposen Nov 19, 2025
8ae3889
chore: update CHANGELOG.md
lposen Nov 19, 2025
c16be16
Merge pull request #712 from Iterable/feature/MOB-12189-add-tests-to-…
lposen Nov 19, 2025
de5ed49
fix: convert retry interval from seconds to milliseconds in RetryPoli…
lposen Nov 19, 2025
051c4c6
Merge pull request #769 from Iterable/feature/SDK-148-remove-fonts-ac…
lposen Nov 20, 2025
e9cb761
fix: update retry policy handling to respect re-initialization
lposen Nov 21, 2025
c48da84
fix: increase retry interval in RetryPolicy configuration from 2 to 5
lposen Nov 21, 2025
ada0a72
fix: update Android `retryInterval` handling to ensure it is correctl…
lposen Nov 21, 2025
177308b
fix: improve handling of retryInterval on re-initialization and add T…
lposen Nov 21, 2025
45be7ed
refactor: remove outdated TODO comments
lposen Nov 21, 2025
0fca9f2
fix: remove unnecessary blank line in Serialization class
lposen Nov 21, 2025
df51ad6
Merge branch 'master' into dependabot/npm_and_yarn/tar-7.5.2
lposen Nov 21, 2025
7d54b6d
Merge pull request #772 from Iterable/dependabot/npm_and_yarn/tar-7.5.2
lposen Nov 21, 2025
df485e9
Merge pull request #782 from Iterable/dependabot/npm_and_yarn/js-yaml…
lposen Nov 21, 2025
5b2ab42
Merge pull request #776 from Iterable/dependabot/npm_and_yarn/react-n…
lposen Nov 21, 2025
1a6d487
fix: ensure consistent formatting of retryInterval in RetryPolicy con…
lposen Nov 21, 2025
e75b775
fix: update Iterable class and config to handle null values in auth t…
lposen Nov 21, 2025
97f5a6c
Merge pull request #786 from Iterable/jwt/SDK-196-android-retryinterv…
lposen Dec 11, 2025
081504b
chore: merge from master
lposen Dec 11, 2025
a2245a2
fix: update expectation in IterableApi test to use strict equality
lposen Dec 11, 2025
2e975e2
chore: release version 2.2.0 with JWT flow
lposen Dec 11, 2025
1c7b504
Merge pull request #740 from Iterable/jwt/master
lposen Dec 11, 2025
936d5c4
Merge branch 'master' into jwt/master
lposen Dec 12, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,5 @@ module.exports = {
},
},
],
ignorePatterns: ['coverage/**/*', 'lib/**/*', 'docs/**/*'],
};
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ ios/generated
android/generated

# Iterable
.env.local
.env
.xcode.env.local
coverage/
Expand Down
39 changes: 35 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,47 @@
## 2.1.0-beta.1
## 2.2.0

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

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

## 2.1.0
### Updates
- SDK is now compatible with both New Architecture and Legacy Architecture. Fix
for #691, #602, #563.

### Fixes
- Dependencies update
- Update SDK so that it has full support for [React Native New Architecture](https://reactnative.dev/architecture/landing-page)
- Add Temporary fix for circular paths, which break expo ([9c09743](https://github.com/Iterable/react-native-sdk/commit/9c09743))

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

## 2.0.4

### Updates
- Added API documentation via Netlify([1087275](https://github.com/Iterable/react-native-sdk/commit/1087275))
- Removed dependency on `react-native-vector-icons`, per issues
[#513](https://github.com/Iterable/react-native-sdk/issues/513),
[#683](https://github.com/Iterable/react-native-sdk/issues/683) and
[#675](https://github.com/Iterable/react-native-sdk/issues/675)
([6ece6e0](https://github.com/Iterable/react-native-sdk/commit/6ece6e0))
- Updated dependencies

## 2.0.3

Expand Down
2 changes: 1 addition & 1 deletion Iterable-React-Native-SDK.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Pod::Spec.new do |s|
s.private_header_files = "ios/**/*.h"

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

# Basic Swift support
s.pod_target_xcconfig = {
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ Iterable's React Native SDK relies on:
_UI Components require additional peer dependencies_
- [React Navigation 6+](https://github.com/react-navigation/react-navigation)
- [React Native Safe Area Context 4+](https://github.com/th3rdwave/react-native-safe-area-context)
- [React Native Vector Icons 10+](https://github.com/oblador/react-native-vector-icons)
- [React Native WebView 13+](https://github.com/react-native-webview/react-native-webview)

- **iOS**
Expand Down Expand Up @@ -120,13 +119,13 @@ For quick reference, the following table lists the versions of the [Android SDK]

| RN SDK Version | Android SDK Version | iOS SDK Version |
| --------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | --------------- |
| [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)
| [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)
| [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)
| [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)
| [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)
| [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)
| [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)
| [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)
| [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)
| [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)
| [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)
| [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)
| [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)
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def kotlin_version = getExtOrDefault("kotlinVersion")
dependencies {
implementation "com.facebook.react:react-android"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
api "com.iterable:iterableapi:3.6.1"
api "com.iterable:iterableapi:3.6.2"
// api project(":iterableapi") // links to local android SDK repo rather than by release
}

Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.iterable.iterableapi.IterableApi;
import com.iterable.iterableapi.IterableAttributionInfo;
import com.iterable.iterableapi.IterableAuthHandler;
import com.iterable.iterableapi.IterableAuthManager;
import com.iterable.iterableapi.IterableConfig;
import com.iterable.iterableapi.IterableCustomActionHandler;
// import com.iterable.iterableapi.IterableEmbeddedManager;
Expand Down Expand Up @@ -98,7 +99,40 @@ public void initializeWithApiKey(String apiKey, ReadableMap configReadableMap, S
configBuilder.setEnableEmbeddedMessaging(configReadableMap.getBoolean("enableEmbeddedMessaging"));
}

IterableApi.initialize(reactContext, apiKey, configBuilder.build());
if (configReadableMap.hasKey("enableEmbeddedMessaging")) {
configBuilder.setEnableEmbeddedMessaging(configReadableMap.getBoolean("enableEmbeddedMessaging"));
}

IterableConfig config = configBuilder.build();
IterableApi.initialize(reactContext, apiKey, config);

// Update retry policy on existing authManager if it was already created
// This fixes the issue where retryInterval is not respected after
// re-initialization
// TODO [SDK-197]: Fix the root cause of this issue, instead of this hack
try {
// Use reflection to access package-private fields and methods
java.lang.reflect.Field configRetryPolicyField = config.getClass().getDeclaredField("retryPolicy");
configRetryPolicyField.setAccessible(true);
Object retryPolicy = configRetryPolicyField.get(config);

if (retryPolicy != null) {
java.lang.reflect.Method getAuthManagerMethod = IterableApi.getInstance().getClass().getDeclaredMethod("getAuthManager");
getAuthManagerMethod.setAccessible(true);
IterableAuthManager authManager = (IterableAuthManager) getAuthManagerMethod.invoke(IterableApi.getInstance());

if (authManager != null) {
// Update the retry policy field on the authManager
java.lang.reflect.Field authRetryPolicyField = authManager.getClass().getDeclaredField("authRetryPolicy");
authRetryPolicyField.setAccessible(true);
authRetryPolicyField.set(authManager, retryPolicy);
IterableLogger.d(TAG, "Updated retry policy on existing authManager");
}
}
} catch (Exception e) {
IterableLogger.e(TAG, "Failed to update retry policy: " + e.getMessage());
}

IterableApi.getInstance().setDeviceAttribute("reactNativeSDKVersion", version);

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

IterableApi.initialize(reactContext, apiKey, configBuilder.build());
IterableConfig config = configBuilder.build();
IterableApi.initialize(reactContext, apiKey, config);

// Update retry policy on existing authManager if it was already created
// This fixes the issue where retryInterval is not respected after
// re-initialization
// TODO [SDK-197]: Fix the root cause of this issue, instead of this hack
try {
// Use reflection to access package-private fields and methods
java.lang.reflect.Field configRetryPolicyField = config.getClass().getDeclaredField("retryPolicy");
configRetryPolicyField.setAccessible(true);
Object retryPolicy = configRetryPolicyField.get(config);

if (retryPolicy != null) {
java.lang.reflect.Method getAuthManagerMethod = IterableApi.getInstance().getClass().getDeclaredMethod("getAuthManager");
getAuthManagerMethod.setAccessible(true);
IterableAuthManager authManager = (IterableAuthManager) getAuthManagerMethod.invoke(IterableApi.getInstance());

if (authManager != null) {
// Update the retry policy field on the authManager
java.lang.reflect.Field authRetryPolicyField = authManager.getClass().getDeclaredField("authRetryPolicy");
authRetryPolicyField.setAccessible(true);
authRetryPolicyField.set(authManager, retryPolicy);
IterableLogger.d(TAG, "Updated retry policy on existing authManager");
}
}
} catch (Exception e) {
IterableLogger.e(TAG, "Failed to update retry policy: " + e.getMessage());
}

IterableApi.getInstance().setDeviceAttribute("reactNativeSDKVersion", version);

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

public void onTokenRegistrationFailed(Throwable object) {
IterableLogger.v(TAG, "Failed to set authToken");
sendEvent(EventName.handleAuthFailureCalled.name(), null);
}

public void addListener(String eventName) {
// Keep: Required for RN built in Event Emitter Calls.
}
Expand Down
16 changes: 12 additions & 4 deletions example/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,19 @@
# 4. Fill in the following fields:
# - Name: A descriptive name for the API key
# - Type: Mobile
# - JWT authentication: Leave **unchecked** (IMPORTANT)
# - JWT authentication: Whether or not you want to use JWT
# 5. Click "Create API Key"
# 6. Copy the generated API key
# 7. Replace the placeholder text next to `ITBL_API_KEY=` with the copied API key
# 6. Copy the generated API key and replace the placeholder text next to
# `ITBL_API_KEY=` with the copied API key
# 7. If you chose to enable JWT authentication, copy the JWT secret and and
# replace the placeholder text next to `ITBL_JWT_SECRET=` with the copied
# JWT secret
ITBL_API_KEY=replace_this_with_your_iterable_api_key
# Your JWT Secret, created when making your API key (see above)
ITBL_JWT_SECRET=replace_this_with_your_jwt_secret
# Is your api token JWT Enabled?
# Must be set to 'true' to enable JWT authentication
ITBL_IS_JWT_ENABLED=true

# Your Iterable user ID or email address
ITBL_ID=replace_this_with_your_user_id_or_email
ITBL_ID=replace_this_with_your_user_id_or_email
21 changes: 14 additions & 7 deletions example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ _example app directory_. To do so, run the following:

```bash
cd ios
pod install
bundle install
bundle exec pod install
```

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

```shell
ITBL_API_KEY=replace_this_with_your_iterable_api_key
ITBL_JWT_SECRET=replace_this_with_your_jwt_secret
ITBL_IS_JWT_ENABLED=true
ITBL_ID=replace_this_with_your_user_id_or_email
```

Replace `replace_this_with_your_iterable_api_key` with your _mobile_ Iterable API key,
and replace `replace_this_with_your_user_id_or_email` with the email or user id
that you use to log into Iterable.
- Replace `replace_this_with_your_iterable_api_key` with your **_mobile_
Iterable API key**
- Replace `replace_this_with_your_jwt_secret` with your **JWT Secret** (if you
have a JWT-enabled API key)
- Set `ITBL_IS_JWT_ENABLED` to true if you have a JWT-enabled key, and false if you do not.
- Replace `replace_this_with_your_user_id_or_email` with the **email or user
id** that you use to log into Iterable.

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

Expand All @@ -54,12 +61,12 @@ To add an API key, do the following:
1. Sign into your Iterable account
2. Go to [Integrations > API Keys](https://app.iterable.com/settings/apiKeys)
3. Click "New API Key" in the top right corner
4. Fill in the followsing fields:
4. Fill in the following fields:
- Name: A descriptive name for the API key
- Type: Mobile
- JWT authentication: Leave **unchecked** (IMPORTANT)
- 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.
5. Click "Create API Key"
6. Copy the generated API key
6. Copy the generated API key and JWT secret into your _.env_ file


## Step 3: Start the Metro Server
Expand Down
2 changes: 0 additions & 2 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,3 @@ dependencies {
implementation jscFlavor
}
}

apply from: file("../../node_modules/react-native-vector-icons/fonts.gradle")
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
package com.iterable;

import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.Base64;
import java.util.Base64.Encoder;

/**
* Utility class to generate JWTs for use with the Iterable API
*
* @author engineering@iterable.com
*/
public class IterableJwtGenerator {
static Encoder encoder = Base64.getUrlEncoder().withoutPadding();

private static final String algorithm = "HmacSHA256";

// Iterable enforces a 1-year maximum token lifetime
private static final Duration maxTokenLifetime = Duration.ofDays(365);

private static long millisToSeconds(long millis) {
return millis / 1000;
}

private static final String encodedHeader = encoder.encodeToString(
"{\"alg\":\"HS256\",\"typ\":\"JWT\"}".getBytes(StandardCharsets.UTF_8)
);

/**
* Generates a JWT from the provided secret, header, and payload. Does not
* validate the header or payload.
*
* @param secret Your organization's shared secret with Iterable
* @param payload The JSON payload
*
* @return a signed JWT
*/
public static String generateToken(String secret, String payload) {
try {
String encodedPayload = encoder.encodeToString(
payload.getBytes(StandardCharsets.UTF_8)
);
String encodedHeaderAndPayload = encodedHeader + "." + encodedPayload;

// HMAC setup
Mac hmac = Mac.getInstance(algorithm);
SecretKeySpec keySpec = new SecretKeySpec(
secret.getBytes(StandardCharsets.UTF_8), algorithm
);
hmac.init(keySpec);

String signature = encoder.encodeToString(
hmac.doFinal(
encodedHeaderAndPayload.getBytes(StandardCharsets.UTF_8)
)
);

return encodedHeaderAndPayload + "." + signature;

} catch (Exception e) {
throw new RuntimeException(e.getMessage());
}
}

/**
* Generates a JWT (issued now, expires after the provided duration).
*
* @param secret Your organization's shared secret with Iterable.
* @param duration The token's expiration time. Up to one year.
* @param email The email to included in the token, or null.
* @param userId The userId to include in the token, or null.
*
* @return A JWT string
*/
public static String generateToken(
String secret, Duration duration, String email, String userId) {

if (duration.compareTo(maxTokenLifetime) > 0)
throw new IllegalArgumentException(
"Duration must be one year or less."
);

if ((userId != null && email != null) || (userId == null && email == null))
throw new IllegalArgumentException(
"The token must include a userId or email, but not both."
);

long now = millisToSeconds(System.currentTimeMillis());

String payload;
if (userId != null)
payload = String.format(
"{ \"userId\": \"%s\", \"iat\": %d, \"exp\": %d }",
userId, now, now + millisToSeconds(duration.toMillis())
);
else
payload = String.format(
"{ \"email\": \"%s\", \"iat\": %d, \"exp\": %d }",
email, now, now + millisToSeconds(duration.toMillis())
);

return generateToken(secret, payload);
}
}
Loading