Skip to content
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,36 @@ public void updateVisibleRows(ReadableArray visibleRows) {
// ---------------------------------------------------------------------------------------
// endregion

// ---------------------------------------------------------------------------------------
// region Embedded APIs

@ReactMethod
public void getEmbeddedPlacements(Promise promise) {
IterableLogger.d(TAG, "getEmbeddedPlacements");

JSONArray testPlacements = new JSONArray();
int[] testPlacementIds = {808, 1121, 112};

try {
for (int placementId : testPlacementIds) {
testPlacements.put(createTestPlacement(placementId));
}

promise.resolve(Serialization.convertJsonToArray(testPlacements));
} catch (JSONException e) {
promise.reject("", "Failed to create test placements");
}
}

private JSONObject createTestPlacement(int placementId) throws JSONException {
JSONObject placement = new JSONObject();
placement.put("placementId", placementId);
return placement;
}

// ---------------------------------------------------------------------------------------
// endregion

// ---------------------------------------------------------------------------------------
// region Private Serialization Functions

Expand Down
5 changes: 5 additions & 0 deletions ios/RNIterableAPI/RNIterableAPI.m
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ @interface RCT_EXTERN_REMAP_MODULE(RNIterableAPI, ReactIterableAPI, NSObject)

RCT_EXTERN_METHOD(updateVisibleRows: (nonnull NSArray *) visibleRows)

// MARK: - SDK Embedded Manager Functions

RCT_EXTERN_METHOD(getEmbeddedPlacements: (RCTPromiseResolveBlock) resolve
rejecter: (RCTPromiseRejectBlock) reject)

// MARK: - SDK Auth Manager Functions

RCT_EXTERN_METHOD(passAlongAuthToken: (NSString *) authToken)
Expand Down
18 changes: 17 additions & 1 deletion ios/RNIterableAPI/ReactIterableAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,22 @@ class ReactIterableAPI: RCTEventEmitter {

inboxSessionManager.updateVisibleRows(visibleRows: serializedRows)
}

// MARK: - SDK Embedded Manager Functions

@objc(getEmbeddedPlacements:rejecter:)
func getEmbeddedPlacements(resolver: @escaping RCTPromiseResolveBlock,
rejecter: @escaping RCTPromiseRejectBlock) {
ITBInfo()

// Create test data
let testPlacements: [[String: Any]] = [
["placementId": "meow"],
["placementId": "woof woof"]
]

resolver(testPlacements)
}

// MARK: - SDK Auth Manager Functions

Expand All @@ -481,7 +497,7 @@ class ReactIterableAPI: RCTEventEmitter {

authHandlerSemaphore.signal()
}

// MARK: Private
private var shouldEmit = false
private let _methodQueue = DispatchQueue(label: String(describing: ReactIterableAPI.self))
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"prettier": "^3.0.3",
"react": "18.3.1",
"react-native": "0.75.3",
"react-native-builder-bob": "^0.40.4",
"react-native-builder-bob": "^0.39.0",
"react-native-safe-area-context": "^4.11.1",
"react-native-vector-icons": "^10.2.0",
"react-native-webview": "^13.12.3",
Expand Down
38 changes: 38 additions & 0 deletions src/embedded/classes/IterableEmbeddedManager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { NativeModules } from 'react-native';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error loading TSDoc config file:
Error encountered for /home/runner/work/react-native-sdk/tsdoc.json:
Unable to resolve "extends" reference to "typedoc/tsdoc.json": Cannot find module 'typedoc/tsdoc.json' from '/home/runner/work/react-native-sdk'
[eslint:tsdoc/syntax]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error loading TSDoc config file:
Error encountered for /home/runner/work/react-native-sdk/tsdoc.json:
Unable to resolve "extends" reference to "typedoc/tsdoc.json": Cannot find module 'typedoc/tsdoc.json' from '/home/runner/work/react-native-sdk'
[eslint:tsdoc/syntax]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error loading TSDoc config file:
Error encountered for /home/runner/work/react-native-sdk/tsdoc.json:
Unable to resolve "extends" reference to "typedoc/tsdoc.json": Cannot find module 'typedoc/tsdoc.json' from '/home/runner/work/react-native-sdk'
[eslint:tsdoc/syntax]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error loading TSDoc config file:
Error encountered for /home/runner/work/react-native-sdk/tsdoc.json:
Unable to resolve "extends" reference to "typedoc/tsdoc.json": Cannot find module 'typedoc/tsdoc.json' from '/home/runner/work/react-native-sdk'
[eslint:tsdoc/syntax]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error loading TSDoc config file:
Error encountered for /home/runner/work/react-native-sdk/tsdoc.json:
Unable to resolve "extends" reference to "typedoc/tsdoc.json": Cannot find module 'typedoc/tsdoc.json' from '/home/runner/work/react-native-sdk'
[eslint:tsdoc/syntax]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error loading TSDoc config file:
Error encountered for /home/runner/work/react-native-sdk/tsdoc.json:
Unable to resolve "extends" reference to "typedoc/tsdoc.json": Cannot find module 'typedoc/tsdoc.json' from '/home/runner/work/react-native-sdk'
[eslint:tsdoc/syntax]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error loading TSDoc config file:
Error encountered for /home/runner/work/react-native-sdk/tsdoc.json:
Unable to resolve "extends" reference to "typedoc/tsdoc.json": Cannot find module 'typedoc/tsdoc.json' from '/home/runner/work/react-native-sdk'
[eslint:tsdoc/syntax]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error loading TSDoc config file:
Error encountered for /home/runner/work/react-native-sdk/tsdoc.json:
Unable to resolve "extends" reference to "typedoc/tsdoc.json": Cannot find module 'typedoc/tsdoc.json' from '/home/runner/work/react-native-sdk'
[eslint:tsdoc/syntax]


import type { IterableLogger } from '../../core/classes/IterableLogger';
import { IterableEmbeddedPlacement } from './IterableEmbeddedPlacement';

const RNIterableAPI = NativeModules.RNIterableAPI;

/**
* Manages embedded messages for the current user.
*
* This class provides methods to interact with embedded messages, including retrieving placements.
*/
export class IterableEmbeddedManager {
private logger?: IterableLogger;

constructor(logger?: IterableLogger) {
this.logger = logger;
}

/**
* Sets the logger instance for this manager
* @param logger - The logger instance to use
*/
setLogger(logger: IterableLogger) {
this.logger = logger;
}

/**
* Retrieve the current user's list of embedded placements.
*
* @returns A Promise that resolves to an array of embedded placements.
*/
getPlacements(): Promise<IterableEmbeddedPlacement[]> {
this.logger?.log('EmbeddedManager.getPlacements');

return RNIterableAPI.getEmbeddedPlacements();
}
}
11 changes: 11 additions & 0 deletions src/embedded/classes/IterableEmbeddedPlacement.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error loading TSDoc config file:
Error encountered for /home/runner/work/react-native-sdk/tsdoc.json:
Unable to resolve "extends" reference to "typedoc/tsdoc.json": Cannot find module 'typedoc/tsdoc.json' from '/home/runner/work/react-native-sdk'
[eslint:tsdoc/syntax]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error loading TSDoc config file:
Error encountered for /home/runner/work/react-native-sdk/tsdoc.json:
Unable to resolve "extends" reference to "typedoc/tsdoc.json": Cannot find module 'typedoc/tsdoc.json' from '/home/runner/work/react-native-sdk'
[eslint:tsdoc/syntax]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error loading TSDoc config file:
Error encountered for /home/runner/work/react-native-sdk/tsdoc.json:
Unable to resolve "extends" reference to "typedoc/tsdoc.json": Cannot find module 'typedoc/tsdoc.json' from '/home/runner/work/react-native-sdk'
[eslint:tsdoc/syntax]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error loading TSDoc config file:
Error encountered for /home/runner/work/react-native-sdk/tsdoc.json:
Unable to resolve "extends" reference to "typedoc/tsdoc.json": Cannot find module 'typedoc/tsdoc.json' from '/home/runner/work/react-native-sdk'
[eslint:tsdoc/syntax]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error loading TSDoc config file:
Error encountered for /home/runner/work/react-native-sdk/tsdoc.json:
Unable to resolve "extends" reference to "typedoc/tsdoc.json": Cannot find module 'typedoc/tsdoc.json' from '/home/runner/work/react-native-sdk'
[eslint:tsdoc/syntax]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error loading TSDoc config file:
Error encountered for /home/runner/work/react-native-sdk/tsdoc.json:
Unable to resolve "extends" reference to "typedoc/tsdoc.json": Cannot find module 'typedoc/tsdoc.json' from '/home/runner/work/react-native-sdk'
[eslint:tsdoc/syntax]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error loading TSDoc config file:
Error encountered for /home/runner/work/react-native-sdk/tsdoc.json:
Unable to resolve "extends" reference to "typedoc/tsdoc.json": Cannot find module 'typedoc/tsdoc.json' from '/home/runner/work/react-native-sdk'
[eslint:tsdoc/syntax]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error loading TSDoc config file:
Error encountered for /home/runner/work/react-native-sdk/tsdoc.json:
Unable to resolve "extends" reference to "typedoc/tsdoc.json": Cannot find module 'typedoc/tsdoc.json' from '/home/runner/work/react-native-sdk'
[eslint:tsdoc/syntax]

* Iterable embedded placement
* Contains placement id and the associated embedded messages
*/
export class IterableEmbeddedPlacement {
readonly placementId: number;

constructor(placementId: number) {
this.placementId = placementId;
}
}
30 changes: 22 additions & 8 deletions src/inApp/classes/IterableInAppManager.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NativeModules } from 'react-native';

import { Iterable } from '../../core/classes/Iterable';
import type { IterableLogger } from '../../core/classes/IterableLogger';
import type {
IterableInAppDeleteSource,
IterableInAppLocation,
Expand All @@ -19,6 +19,20 @@ const RNIterableAPI = NativeModules.RNIterableAPI;
* The `inAppManager` property of an `Iterable` instance is set to an instance of this class.
*/
export class IterableInAppManager {
private logger?: IterableLogger;

constructor(logger?: IterableLogger) {
this.logger = logger;
}

/**
* Sets the logger instance for this manager
* @param logger - The logger instance to use
*/
setLogger(logger: IterableLogger) {
this.logger = logger;
}

/**
* Retrieve the current user's list of in-app messages stored in the local queue.
*
Expand All @@ -36,7 +50,7 @@ export class IterableInAppManager {
* @returns A Promise that resolves to an array of in-app messages.
*/
getMessages(): Promise<IterableInAppMessage[]> {
Iterable?.logger?.log('InAppManager.getMessages');
this.logger?.log('InAppManager.getMessages');

return RNIterableAPI.getInAppMessages();
}
Expand All @@ -59,7 +73,7 @@ export class IterableInAppManager {
* @returns A Promise that resolves to an array of messages marked as `saveToInbox`.
*/
getInboxMessages(): Promise<IterableInAppMessage[]> {
Iterable?.logger?.log('InAppManager.getInboxMessages');
this.logger?.log('InAppManager.getInboxMessages');

return RNIterableAPI.getInboxMessages();
}
Expand All @@ -86,7 +100,7 @@ export class IterableInAppManager {
message: IterableInAppMessage,
consume: boolean
): Promise<string | undefined> {
Iterable?.logger?.log('InAppManager.show');
this.logger?.log('InAppManager.show');

return RNIterableAPI.showMessage(message.messageId, consume);
}
Expand Down Expand Up @@ -114,7 +128,7 @@ export class IterableInAppManager {
location: IterableInAppLocation,
source: IterableInAppDeleteSource
): void {
Iterable?.logger?.log('InAppManager.remove');
this.logger?.log('InAppManager.remove');

return RNIterableAPI.removeMessage(message.messageId, location, source);
}
Expand All @@ -131,7 +145,7 @@ export class IterableInAppManager {
* ```
*/
setReadForMessage(message: IterableInAppMessage, read: boolean) {
Iterable?.logger?.log('InAppManager.setRead');
this.logger?.log('InAppManager.setRead');

RNIterableAPI.setReadForMessage(message.messageId, read);
}
Expand All @@ -151,7 +165,7 @@ export class IterableInAppManager {
getHtmlContentForMessage(
message: IterableInAppMessage
): Promise<IterableHtmlInAppContent> {
Iterable?.logger?.log('InAppManager.getHtmlContentForMessage');
this.logger?.log('InAppManager.getHtmlContentForMessage');

return RNIterableAPI.getHtmlInAppContentForMessage(message.messageId);
}
Expand All @@ -171,7 +185,7 @@ export class IterableInAppManager {
* ```
*/
setAutoDisplayPaused(paused: boolean) {
Iterable?.logger?.log('InAppManager.setAutoDisplayPaused');
this.logger?.log('InAppManager.setAutoDisplayPaused');

RNIterableAPI.setAutoDisplayPaused(paused);
}
Expand Down
37 changes: 5 additions & 32 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,6 @@ __metadata:
languageName: node

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are these changes from? There shouldn't be changes to the lock file if you just do yarn install

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im gonna make a fresh PR.

linkType: hard

"@ark/schema@npm:0.45.9":
version: 0.45.9
resolution: "@ark/schema@npm:0.45.9"
dependencies:
"@ark/util": 0.45.9
checksum: 8d28c910ef6ae379c61a82db2f7e8160d96eb25fb73a56bda5f9c63cc86abca12552d2bb8cd3dd9aff010f5464f9834e33285eca51ea7da16f2143e050cc901a
languageName: node
linkType: hard

"@ark/util@npm:0.45.9":
version: 0.45.9
resolution: "@ark/util@npm:0.45.9"
checksum: ddd1fc89c45b61e5d52cb92203990492a5115aea58a8e8bf5ff24e28103fce331593e0c374a086554fb6feb375ddd759c07e751aadc7f3ab3c6138dc3ee362cf
languageName: node
linkType: hard

"@babel/code-frame@npm:^7.0.0, @babel/code-frame@npm:^7.12.13, @babel/code-frame@npm:^7.24.7":
version: 7.24.7
resolution: "@babel/code-frame@npm:7.24.7"
Expand Down Expand Up @@ -3093,7 +3077,7 @@ __metadata:
prettier: ^3.0.3
react: 18.3.1
react-native: 0.75.3
react-native-builder-bob: ^0.40.4
Comment thread
evantk91 marked this conversation as resolved.
react-native-builder-bob: ^0.39.0
react-native-safe-area-context: ^4.11.1
react-native-vector-icons: ^10.2.0
react-native-webview: ^13.12.3
Expand Down Expand Up @@ -5148,16 +5132,6 @@ __metadata:
languageName: node
linkType: hard

"arktype@npm:^2.1.15":
version: 2.1.19
resolution: "arktype@npm:2.1.19"
dependencies:
"@ark/schema": 0.45.9
"@ark/util": 0.45.9
checksum: cf656f9aa3797d56572d49a8499a4156fbbe25eacbd075f4c60770876fd1fbde6b6285f1b367de93e14858651f6a1df1db3de99d6a5f642e1fa61f421fae0712
languageName: node
linkType: hard

"array-buffer-byte-length@npm:^1.0.1":
version: 1.0.1
resolution: "array-buffer-byte-length@npm:1.0.1"
Expand Down Expand Up @@ -12689,17 +12663,16 @@ __metadata:
languageName: node
linkType: hard

"react-native-builder-bob@npm:^0.40.4":
version: 0.40.4
resolution: "react-native-builder-bob@npm:0.40.4"
"react-native-builder-bob@npm:^0.39.0":
version: 0.39.1
resolution: "react-native-builder-bob@npm:0.39.1"
dependencies:
"@babel/core": ^7.25.2
"@babel/plugin-transform-strict-mode": ^7.24.7
"@babel/preset-env": ^7.25.2
"@babel/preset-flow": ^7.24.7
"@babel/preset-react": ^7.24.7
"@babel/preset-typescript": ^7.24.7
arktype: ^2.1.15
babel-plugin-module-resolver: ^5.0.2
browserslist: ^4.20.4
cross-spawn: ^7.0.3
Expand All @@ -12717,7 +12690,7 @@ __metadata:
yargs: ^17.5.1
bin:
bob: bin/bob
checksum: 2b3576a5b3afb142400427f51197485fd0a8d7611b2ca6edb610fbcf320279c5951846c3ebe00715904e808f91106367e1f95c4e32f29405a07fb517a87927bb
checksum: d17f017beae07455997c63e36ca28fee853c18308939f30f00b471b3beafafb98beb5dce9a5f1634da3c5fbbf2538666048a88bd144b374d3998c8763da064a0
languageName: node
linkType: hard

Expand Down