-
Notifications
You must be signed in to change notification settings - Fork 43
[MOB-12261] Add IterableEmbeddedManager class #742
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 10 commits
15e1894
952eebe
2a62913
789ae83
9940f46
e7d4ecb
4441759
8201c4d
e13756e
79926df
5206902
2b4da8a
11f8227
935cf22
047f94b
92c8c9e
d365761
b3ce46c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -20,6 +20,7 @@ import { IterableAuthResponse } from './IterableAuthResponse'; | |||||
| import type { IterableCommerceItem } from './IterableCommerceItem'; | ||||||
| import { IterableConfig } from './IterableConfig'; | ||||||
| import { IterableLogger } from './IterableLogger'; | ||||||
| import { IterableEmbeddedManager } from '../../embedded/classes/IterableEmbeddedManager'; | ||||||
|
|
||||||
| const RNEventEmitter = new NativeEventEmitter(RNIterableAPI); | ||||||
|
|
||||||
|
|
@@ -96,6 +97,27 @@ export class Iterable { | |||||
| */ | ||||||
| static authManager: IterableAuthManager = new IterableAuthManager(); | ||||||
|
|
||||||
| /** | ||||||
| * Embedded message manager for the current user. | ||||||
| * | ||||||
| * This property provides access to embedded message functionality including | ||||||
| * retrieving messages, displaying messages, removing messages, and more. | ||||||
| * | ||||||
| * **Documentation** | ||||||
| * - [Embedded Messaging Overview](https://support.iterable.com/hc/en-us/articles/23060529977364-Embedded-Messaging-Overview) | ||||||
| * - [Android Embedded Messaging](https://support.iterable.com/hc/en-us/articles/23061877893652-Embedded-Messages-with-Iterable-s-Android-SDK) | ||||||
| * - [iOS Embedded Messaging](https://support.iterable.com/hc/en-us/articles/23061840746900-Embedded-Messages-with-Iterable-s-iOS-SDK) | ||||||
| * | ||||||
| * @example | ||||||
| * ```typescript | ||||||
| * Iterable.embeddedManager.getMessages().then(messages => { | ||||||
| * console.log('Messages:', messages); | ||||||
| * }); | ||||||
| * ``` | ||||||
| */ | ||||||
| static embeddedManager: IterableEmbeddedManager = | ||||||
| new IterableEmbeddedManager(); | ||||||
|
|
||||||
| /** | ||||||
| * Initializes the Iterable React Native SDK in your app's Javascript or Typescript code. | ||||||
| * | ||||||
|
|
@@ -172,6 +194,10 @@ export class Iterable { | |||||
|
|
||||||
| IterableLogger.setLoggingEnabled(config.logReactNativeSdkCalls ?? true); | ||||||
| IterableLogger.setLogLevel(config.logLevel); | ||||||
|
|
||||||
| Iterable.embeddedManager.setEnabled( | ||||||
| config.embeddedMessagingEnabled === true | ||||||
|
||||||
| config.embeddedMessagingEnabled === true | |
| config.embeddedMessagingEnabled ?? false |
Copilot
AI
Nov 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new embeddedMessagingEnabled configuration option and embeddedManager integration lack test coverage. Similar configuration options like logReactNativeSdkCalls have comprehensive test coverage in Iterable.test.ts.
Consider adding tests for:
- Default value of
embeddedMessagingEnabled(should befalse) embeddedMessagingEnabledbeing included in thetoDict()outputembeddedManager.isEnabledbeing set correctly duringIterable.initialize()based on the config valueembeddedManagerbeing accessible as a static property
Example test structure:
describe('embeddedManager', () => {
it('should be disabled by default', () => {
const config = new IterableConfig();
expect(config.embeddedMessagingEnabled).toBe(false);
expect(Iterable.embeddedManager.isEnabled).toBe(false);
});
it('should enable embeddedManager when config is set', async () => {
const config = new IterableConfig();
config.embeddedMessagingEnabled = true;
await Iterable.initialize('test-key', config);
expect(Iterable.embeddedManager.isEnabled).toBe(true);
});
});| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -329,6 +329,16 @@ export class IterableConfig { | |
| */ | ||
| encryptionEnforced = false; | ||
|
|
||
| /** | ||
| * Should the SDK enable and use embedded messaging? | ||
| * | ||
| * **Documentation** | ||
| * - [Embedded Messaging Overview](https://support.iterable.com/hc/en-us/articles/23060529977364-Embedded-Messaging-Overview) | ||
| * - [Android Embedded Messaging](https://support.iterable.com/hc/en-us/articles/23061877893652-Embedded-Messages-with-Iterable-s-Android-SDK) | ||
| * - [iOS Embedded Messaging](https://support.iterable.com/hc/en-us/articles/23061840746900-Embedded-Messages-with-Iterable-s-iOS-SDK) | ||
| */ | ||
| embeddedMessagingEnabled = false; | ||
|
||
|
|
||
| /** | ||
| * Converts the IterableConfig instance to a dictionary object. | ||
| * | ||
|
|
@@ -378,6 +388,7 @@ export class IterableConfig { | |
| pushPlatform: this.pushPlatform, | ||
| encryptionEnforced: this.encryptionEnforced, | ||
| retryPolicy: this.retryPolicy, | ||
| embeddedMessagingEnabled: this.embeddedMessagingEnabled, | ||
| }; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,26 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Manages embedded messages from Iterable. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Provides embedded message functionality including retrieving messages, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| * displaying messages, removing messages, and more. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| * **Documentation** | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| * - [Embedded Messaging Overview](https://support.iterable.com/hc/en-us/articles/23060529977364-Embedded-Messaging-Overview) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| * - [Android Embedded Messaging](https://support.iterable.com/hc/en-us/articles/23061877893652-Embedded-Messages-with-Iterable-s-Android-SDK) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| * - [iOS Embedded Messaging](https://support.iterable.com/hc/en-us/articles/23061840746900-Embedded-Messages-with-Iterable-s-iOS-SDK) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| export class IterableEmbeddedManager { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Whether the embedded manager is enabled. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| isEnabled = false; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Sets whether the embedded manager is enabled. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| * @param enabled - Whether the embedded manager is enabled. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| setEnabled(enabled: boolean) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.isEnabled = enabled; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| isEnabled = false; | |
| /** | |
| * Sets whether the embedded manager is enabled. | |
| * | |
| * @param enabled - Whether the embedded manager is enabled. | |
| */ | |
| setEnabled(enabled: boolean) { | |
| this.isEnabled = enabled; | |
| private _isEnabled = false; | |
| /** | |
| * Gets whether the embedded manager is enabled. | |
| */ | |
| get isEnabled(): boolean { | |
| return this._isEnabled; | |
| } | |
| /** | |
| * Sets whether the embedded manager is enabled. | |
| * | |
| * @param enabled - Whether the embedded manager is enabled. | |
| */ | |
| setEnabled(enabled: boolean) { | |
| this._isEnabled = enabled; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export * from './IterableEmbeddedManager'; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export * from './classes'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation example shows calling
getMessages()method, but theIterableEmbeddedManagerclass does not implement this method. The current implementation only hasisEnabledproperty andsetEnabled()method.Either update the example to reflect the current API:
Or remove the example until
getMessages()is implemented.