@adobe/react-native-aepmessaging 7.2.1 → 7.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/RCTAEPMessaging.podspec +1 -1
- package/README.md +145 -16
- package/android/src/main/java/com/adobe/marketing/mobile/reactnative/messaging/RCTAEPMessagingConstants.java +3 -0
- package/android/src/main/java/com/adobe/marketing/mobile/reactnative/messaging/RCTAEPMessagingModule.java +103 -33
- package/babel.config.js +3 -0
- package/dist/module/Messaging.js +334 -0
- package/dist/module/Messaging.js.map +1 -0
- package/dist/module/index.js +30 -0
- package/dist/module/index.js.map +1 -0
- package/dist/module/models/ContentCard.js +24 -0
- package/dist/module/models/ContentCard.js.map +1 -0
- package/dist/{models → module/models}/HTMLProposition.js +8 -9
- package/dist/module/models/HTMLProposition.js.map +1 -0
- package/dist/module/models/InAppMessage.js +4 -0
- package/dist/module/models/InAppMessage.js.map +1 -0
- package/dist/module/models/JSONProposition.js +22 -0
- package/dist/module/models/JSONProposition.js.map +1 -0
- package/dist/module/models/Message.js +182 -0
- package/dist/module/models/Message.js.map +1 -0
- package/dist/module/models/MessagingDelegate.js +4 -0
- package/dist/module/models/MessagingDelegate.js.map +1 -0
- package/dist/module/models/MessagingEdgeEventType.js +24 -0
- package/dist/module/models/MessagingEdgeEventType.js.map +1 -0
- package/dist/module/models/MessagingProposition.js +57 -0
- package/dist/module/models/MessagingProposition.js.map +1 -0
- package/dist/module/models/MessagingPropositionItem.js +4 -0
- package/dist/module/models/MessagingPropositionItem.js.map +1 -0
- package/dist/module/models/PersonalizationSchema.js +26 -0
- package/dist/module/models/PersonalizationSchema.js.map +1 -0
- package/dist/module/models/PropositionItem.js +113 -0
- package/dist/module/models/PropositionItem.js.map +1 -0
- package/dist/module/models/ScopeDetails.js +2 -0
- package/dist/module/models/ScopeDetails.js.map +1 -0
- package/dist/{models/JSONProposition.js → module/models/index.js} +14 -12
- package/dist/module/models/index.js.map +1 -0
- package/dist/module/ui/components/Button/Button.js +57 -0
- package/dist/module/ui/components/Button/Button.js.map +1 -0
- package/dist/module/ui/components/Button/Button.spec.js +476 -0
- package/dist/module/ui/components/Button/Button.spec.js.map +1 -0
- package/dist/module/ui/components/ContentCardView/ContentCardView.js +257 -0
- package/dist/module/ui/components/ContentCardView/ContentCardView.js.map +1 -0
- package/dist/module/ui/components/ContentCardView/ContentCardView.spec.js +363 -0
- package/dist/module/ui/components/ContentCardView/ContentCardView.spec.js.map +1 -0
- package/dist/module/ui/components/DismissButton/DismissButton.js +70 -0
- package/dist/module/ui/components/DismissButton/DismissButton.js.map +1 -0
- package/dist/module/ui/components/DismissButton/DismissButton.spec.js +279 -0
- package/dist/module/ui/components/DismissButton/DismissButton.spec.js.map +1 -0
- package/dist/module/ui/components/FullScreenCenterView/FullScreenCenterView.js +34 -0
- package/dist/module/ui/components/FullScreenCenterView/FullScreenCenterView.js.map +1 -0
- package/dist/module/ui/components/Inbox/EmptyState.js +64 -0
- package/dist/module/ui/components/Inbox/EmptyState.js.map +1 -0
- package/dist/module/ui/components/Inbox/Inbox.js +235 -0
- package/dist/module/ui/components/Inbox/Inbox.js.map +1 -0
- package/dist/module/ui/components/Inbox/Inbox.spec.js +847 -0
- package/dist/module/ui/components/Inbox/Inbox.spec.js.map +1 -0
- package/dist/module/ui/components/Pagination/Pagination.js +176 -0
- package/dist/module/ui/components/Pagination/Pagination.js.map +1 -0
- package/dist/module/ui/components/Pagination/Pagination.spec.js +193 -0
- package/dist/module/ui/components/Pagination/Pagination.spec.js.map +1 -0
- package/dist/module/ui/components/UnreadIcon/UnreadIcon.js +184 -0
- package/dist/module/ui/components/UnreadIcon/UnreadIcon.js.map +1 -0
- package/dist/module/ui/components/UnreadIcon/UnreadIcon.spec.js +815 -0
- package/dist/module/ui/components/UnreadIcon/UnreadIcon.spec.js.map +1 -0
- package/dist/{models/ContentCard.js → module/ui/components/index.js} +12 -12
- package/dist/module/ui/components/index.js.map +1 -0
- package/dist/module/ui/hooks/index.js +18 -0
- package/dist/module/ui/hooks/index.js.map +1 -0
- package/dist/module/ui/hooks/useAspectRatio.js +33 -0
- package/dist/module/ui/hooks/useAspectRatio.js.map +1 -0
- package/dist/module/ui/hooks/useAspectRatio.spec.js +65 -0
- package/dist/module/ui/hooks/useAspectRatio.spec.js.map +1 -0
- package/dist/module/ui/hooks/useContentCardUI.js +51 -0
- package/dist/module/ui/hooks/useContentCardUI.js.map +1 -0
- package/dist/module/ui/hooks/useContentCardUI.spec.js +85 -0
- package/dist/module/ui/hooks/useContentCardUI.spec.js.map +1 -0
- package/dist/module/ui/hooks/useInbox.js +49 -0
- package/dist/module/ui/hooks/useInbox.js.map +1 -0
- package/dist/module/ui/hooks/useInbox.spec.js +93 -0
- package/dist/module/ui/hooks/useInbox.spec.js.map +1 -0
- package/dist/module/ui/hooks/useInboxSettings.js +26 -0
- package/dist/module/ui/hooks/useInboxSettings.js.map +1 -0
- package/dist/module/ui/hooks/useInboxSettings.spec.js +50 -0
- package/dist/module/ui/hooks/useInboxSettings.spec.js.map +1 -0
- package/dist/module/ui/index.js +10 -0
- package/dist/module/ui/index.js.map +1 -0
- package/dist/module/ui/providers/InboxProvider.js +27 -0
- package/dist/module/ui/providers/InboxProvider.js.map +1 -0
- package/dist/module/ui/theme/Theme.js +2 -0
- package/dist/module/ui/theme/Theme.js.map +1 -0
- package/dist/module/ui/theme/ThemeProvider.js +112 -0
- package/dist/module/ui/theme/ThemeProvider.js.map +1 -0
- package/dist/{models/InAppMessage.js → module/ui/theme/index.js} +6 -3
- package/dist/module/ui/theme/index.js.map +1 -0
- package/dist/module/ui/types/ContentViewEvent.js +2 -0
- package/dist/module/ui/types/ContentViewEvent.js.map +1 -0
- package/dist/module/ui/types/Templates.js +26 -0
- package/dist/module/ui/types/Templates.js.map +1 -0
- package/dist/{models/ScopeDetails.js → module/ui/types/index.js} +6 -3
- package/dist/module/ui/types/index.js.map +1 -0
- package/dist/module/ui/utils/generateCardHash.js +50 -0
- package/dist/module/ui/utils/generateCardHash.js.map +1 -0
- package/dist/module/ui/utils/generateCardHash.spec.js +103 -0
- package/dist/module/ui/utils/generateCardHash.spec.js.map +1 -0
- package/dist/module/ui/utils/inboxStorage.js +65 -0
- package/dist/module/ui/utils/inboxStorage.js.map +1 -0
- package/dist/module/ui/utils/inboxStorage.spec.js +123 -0
- package/dist/module/ui/utils/inboxStorage.spec.js.map +1 -0
- package/dist/module/ui/utils/index.js +5 -0
- package/dist/module/ui/utils/index.js.map +1 -0
- package/dist/{Messaging.d.ts → typescript/Messaging.d.ts} +23 -7
- package/dist/typescript/Messaging.d.ts.map +1 -0
- package/dist/{index.d.ts → typescript/index.d.ts} +4 -2
- package/dist/typescript/index.d.ts.map +1 -0
- package/dist/typescript/models/ContentCard.d.ts +57 -0
- package/dist/typescript/models/ContentCard.d.ts.map +1 -0
- package/dist/{models → typescript/models}/HTMLProposition.d.ts +1 -0
- package/dist/typescript/models/HTMLProposition.d.ts.map +1 -0
- package/dist/{models → typescript/models}/InAppMessage.d.ts +1 -0
- package/dist/typescript/models/InAppMessage.d.ts.map +1 -0
- package/dist/{models → typescript/models}/JSONProposition.d.ts +1 -0
- package/dist/typescript/models/JSONProposition.d.ts.map +1 -0
- package/dist/{models → typescript/models}/Message.d.ts +14 -0
- package/dist/typescript/models/Message.d.ts.map +1 -0
- package/dist/{models → typescript/models}/MessagingDelegate.d.ts +1 -0
- package/dist/typescript/models/MessagingDelegate.d.ts.map +1 -0
- package/dist/{models → typescript/models}/MessagingEdgeEventType.d.ts +1 -0
- package/dist/typescript/models/MessagingEdgeEventType.d.ts.map +1 -0
- package/dist/{models → typescript/models}/MessagingProposition.d.ts +1 -0
- package/dist/typescript/models/MessagingProposition.d.ts.map +1 -0
- package/dist/{models → typescript/models}/MessagingPropositionItem.d.ts +1 -0
- package/dist/typescript/models/MessagingPropositionItem.d.ts.map +1 -0
- package/dist/{models → typescript/models}/PersonalizationSchema.d.ts +2 -0
- package/dist/typescript/models/PersonalizationSchema.d.ts.map +1 -0
- package/dist/{models → typescript/models}/PropositionItem.d.ts +1 -0
- package/dist/typescript/models/PropositionItem.d.ts.map +1 -0
- package/dist/{models → typescript/models}/ScopeDetails.d.ts +1 -0
- package/dist/typescript/models/ScopeDetails.d.ts.map +1 -0
- package/dist/typescript/models/index.d.ts +11 -0
- package/dist/typescript/models/index.d.ts.map +1 -0
- package/dist/typescript/ui/components/Button/Button.d.ts +14 -0
- package/dist/typescript/ui/components/Button/Button.d.ts.map +1 -0
- package/dist/typescript/ui/components/Button/Button.spec.d.ts +2 -0
- package/dist/typescript/ui/components/Button/Button.spec.d.ts.map +1 -0
- package/dist/typescript/ui/components/ContentCardView/ContentCardView.d.ts +39 -0
- package/dist/typescript/ui/components/ContentCardView/ContentCardView.d.ts.map +1 -0
- package/dist/typescript/ui/components/ContentCardView/ContentCardView.spec.d.ts +2 -0
- package/dist/typescript/ui/components/ContentCardView/ContentCardView.spec.d.ts.map +1 -0
- package/dist/typescript/ui/components/DismissButton/DismissButton.d.ts +13 -0
- package/dist/typescript/ui/components/DismissButton/DismissButton.d.ts.map +1 -0
- package/dist/typescript/ui/components/DismissButton/DismissButton.spec.d.ts +2 -0
- package/dist/typescript/ui/components/DismissButton/DismissButton.spec.d.ts.map +1 -0
- package/dist/typescript/ui/components/FullScreenCenterView/FullScreenCenterView.d.ts +5 -0
- package/dist/typescript/ui/components/FullScreenCenterView/FullScreenCenterView.d.ts.map +1 -0
- package/dist/typescript/ui/components/Inbox/EmptyState.d.ts +19 -0
- package/dist/typescript/ui/components/Inbox/EmptyState.d.ts.map +1 -0
- package/dist/typescript/ui/components/Inbox/Inbox.d.ts +21 -0
- package/dist/typescript/ui/components/Inbox/Inbox.d.ts.map +1 -0
- package/dist/typescript/ui/components/Inbox/Inbox.spec.d.ts +2 -0
- package/dist/typescript/ui/components/Inbox/Inbox.spec.d.ts.map +1 -0
- package/dist/typescript/ui/components/Pagination/Pagination.d.ts +14 -0
- package/dist/typescript/ui/components/Pagination/Pagination.d.ts.map +1 -0
- package/dist/typescript/ui/components/Pagination/Pagination.spec.d.ts +2 -0
- package/dist/typescript/ui/components/Pagination/Pagination.spec.d.ts.map +1 -0
- package/dist/typescript/ui/components/UnreadIcon/UnreadIcon.d.ts +14 -0
- package/dist/typescript/ui/components/UnreadIcon/UnreadIcon.d.ts.map +1 -0
- package/dist/typescript/ui/components/UnreadIcon/UnreadIcon.spec.d.ts +2 -0
- package/dist/typescript/ui/components/UnreadIcon/UnreadIcon.spec.d.ts.map +1 -0
- package/dist/typescript/ui/components/index.d.ts +10 -0
- package/dist/typescript/ui/components/index.d.ts.map +1 -0
- package/dist/typescript/ui/hooks/index.d.ts +4 -0
- package/dist/typescript/ui/hooks/index.d.ts.map +1 -0
- package/dist/typescript/ui/hooks/useAspectRatio.d.ts +3 -0
- package/dist/typescript/ui/hooks/useAspectRatio.d.ts.map +1 -0
- package/dist/typescript/ui/hooks/useAspectRatio.spec.d.ts +2 -0
- package/dist/typescript/ui/hooks/useAspectRatio.spec.d.ts.map +1 -0
- package/dist/typescript/ui/hooks/useContentCardUI.d.ts +14 -0
- package/dist/typescript/ui/hooks/useContentCardUI.d.ts.map +1 -0
- package/dist/typescript/ui/hooks/useContentCardUI.spec.d.ts +2 -0
- package/dist/typescript/ui/hooks/useContentCardUI.spec.d.ts.map +1 -0
- package/dist/typescript/ui/hooks/useInbox.d.ts +12 -0
- package/dist/typescript/ui/hooks/useInbox.d.ts.map +1 -0
- package/dist/typescript/ui/hooks/useInbox.spec.d.ts +2 -0
- package/dist/typescript/ui/hooks/useInbox.spec.d.ts.map +1 -0
- package/dist/typescript/ui/hooks/useInboxSettings.d.ts +7 -0
- package/dist/typescript/ui/hooks/useInboxSettings.d.ts.map +1 -0
- package/dist/typescript/ui/hooks/useInboxSettings.spec.d.ts +2 -0
- package/dist/typescript/ui/hooks/useInboxSettings.spec.d.ts.map +1 -0
- package/dist/typescript/ui/index.d.ts +8 -0
- package/dist/typescript/ui/index.d.ts.map +1 -0
- package/dist/typescript/ui/providers/InboxProvider.d.ts +56 -0
- package/dist/typescript/ui/providers/InboxProvider.d.ts.map +1 -0
- package/dist/typescript/ui/theme/Theme.d.ts +44 -0
- package/dist/typescript/ui/theme/Theme.d.ts.map +1 -0
- package/dist/typescript/ui/theme/ThemeProvider.d.ts +21 -0
- package/dist/typescript/ui/theme/ThemeProvider.d.ts.map +1 -0
- package/dist/typescript/ui/theme/index.d.ts +3 -0
- package/dist/typescript/ui/theme/index.d.ts.map +1 -0
- package/dist/typescript/ui/types/ContentViewEvent.d.ts +9 -0
- package/dist/typescript/ui/types/ContentViewEvent.d.ts.map +1 -0
- package/dist/typescript/ui/types/Templates.d.ts +43 -0
- package/dist/typescript/ui/types/Templates.d.ts.map +1 -0
- package/dist/typescript/ui/types/index.d.ts +3 -0
- package/dist/typescript/ui/types/index.d.ts.map +1 -0
- package/dist/typescript/ui/utils/generateCardHash.d.ts +21 -0
- package/dist/typescript/ui/utils/generateCardHash.d.ts.map +1 -0
- package/dist/typescript/ui/utils/generateCardHash.spec.d.ts +2 -0
- package/dist/typescript/ui/utils/generateCardHash.spec.d.ts.map +1 -0
- package/dist/typescript/ui/utils/inboxStorage.d.ts +20 -0
- package/dist/typescript/ui/utils/inboxStorage.d.ts.map +1 -0
- package/dist/typescript/ui/utils/inboxStorage.spec.d.ts +2 -0
- package/dist/typescript/ui/utils/inboxStorage.spec.d.ts.map +1 -0
- package/dist/typescript/ui/utils/index.d.ts +3 -0
- package/dist/typescript/ui/utils/index.d.ts.map +1 -0
- package/ios/src/RCTAEPMessaging.mm +15 -0
- package/ios/src/RCTAEPMessaging.swift +61 -3
- package/ios/src/RCTAEPMessagingConstants.swift +4 -1
- package/jest.config.js +15 -0
- package/package.json +33 -5
- package/src/Messaging.ts +288 -32
- package/src/index.ts +3 -3
- package/src/models/ContentCard.ts +52 -27
- package/src/models/HTMLProposition.ts +1 -1
- package/src/models/JSONProposition.ts +1 -1
- package/src/models/Message.ts +50 -0
- package/src/models/PersonalizationSchema.ts +1 -0
- package/src/models/index.ts +22 -0
- package/src/ui/components/Button/Button.spec.tsx +496 -0
- package/src/ui/components/Button/Button.tsx +76 -0
- package/src/ui/components/ContentCardView/ContentCardView.spec.tsx +278 -0
- package/src/ui/components/ContentCardView/ContentCardView.tsx +400 -0
- package/src/ui/components/DismissButton/DismissButton.spec.tsx +314 -0
- package/src/ui/components/DismissButton/DismissButton.tsx +100 -0
- package/src/ui/components/FullScreenCenterView/FullScreenCenterView.tsx +32 -0
- package/src/ui/components/Inbox/EmptyState.tsx +89 -0
- package/src/ui/components/Inbox/Inbox.spec.tsx +478 -0
- package/src/ui/components/Inbox/Inbox.tsx +275 -0
- package/src/ui/components/Pagination/Pagination.spec.tsx +159 -0
- package/src/ui/components/Pagination/Pagination.tsx +222 -0
- package/src/ui/components/UnreadIcon/UnreadIcon.spec.tsx +878 -0
- package/src/ui/components/UnreadIcon/UnreadIcon.tsx +234 -0
- package/src/ui/components/index.ts +22 -0
- package/{dist/models/MessagingPropositionItem.js → src/ui/hooks/index.ts} +5 -4
- package/src/ui/hooks/useAspectRatio.spec.tsx +66 -0
- package/src/ui/hooks/useAspectRatio.tsx +39 -0
- package/src/ui/hooks/useContentCardUI.spec.tsx +82 -0
- package/src/ui/hooks/useContentCardUI.ts +48 -0
- package/src/ui/hooks/useInbox.spec.tsx +87 -0
- package/src/ui/hooks/useInbox.ts +46 -0
- package/src/ui/hooks/useInboxSettings.spec.tsx +41 -0
- package/src/ui/hooks/useInboxSettings.ts +24 -0
- package/src/ui/index.ts +7 -0
- package/src/ui/providers/InboxProvider.tsx +79 -0
- package/src/ui/theme/Theme.ts +57 -0
- package/src/ui/theme/ThemeProvider.tsx +120 -0
- package/src/ui/theme/index.ts +14 -0
- package/src/ui/types/ContentViewEvent.ts +20 -0
- package/src/ui/types/Templates.ts +77 -0
- package/src/ui/types/index.ts +14 -0
- package/src/ui/utils/generateCardHash.spec.tsx +86 -0
- package/src/ui/utils/generateCardHash.ts +59 -0
- package/src/ui/utils/inboxStorage.spec.tsx +136 -0
- package/src/ui/utils/inboxStorage.ts +64 -0
- package/src/ui/utils/index.ts +3 -0
- package/tutorials/ContentCardCustomizationGuide.md +661 -0
- package/tutorials/ContentCards.md +419 -0
- package/tutorials/In-App Messaging.md +31 -0
- package/tutorials/Inbox.md +515 -0
- package/tutorials/resources/image-only-template.png +0 -0
- package/tutorials/resources/large-image-template.png +0 -0
- package/tutorials/resources/small-image-template.png +0 -0
- package/dist/Messaging.js +0 -151
- package/dist/Messaging.js.map +0 -1
- package/dist/index.js +0 -34
- package/dist/index.js.map +0 -1
- package/dist/models/ContentCard.d.ts +0 -51
- package/dist/models/ContentCard.js.map +0 -1
- package/dist/models/HTMLProposition.js.map +0 -1
- package/dist/models/InAppMessage.js.map +0 -1
- package/dist/models/JSONProposition.js.map +0 -1
- package/dist/models/Message.js +0 -114
- package/dist/models/Message.js.map +0 -1
- package/dist/models/MessagingDelegate.js +0 -14
- package/dist/models/MessagingDelegate.js.map +0 -1
- package/dist/models/MessagingEdgeEventType.js +0 -24
- package/dist/models/MessagingEdgeEventType.js.map +0 -1
- package/dist/models/MessagingProposition.js +0 -59
- package/dist/models/MessagingProposition.js.map +0 -1
- package/dist/models/MessagingPropositionItem.js.map +0 -1
- package/dist/models/PersonalizationSchema.js +0 -25
- package/dist/models/PersonalizationSchema.js.map +0 -1
- package/dist/models/PropositionItem.js +0 -78
- package/dist/models/PropositionItem.js.map +0 -1
- package/dist/models/ScopeDetails.js.map +0 -1
package/src/Messaging.ts
CHANGED
|
@@ -14,12 +14,18 @@ import {
|
|
|
14
14
|
NativeModules,
|
|
15
15
|
NativeEventEmitter,
|
|
16
16
|
NativeModule,
|
|
17
|
-
Platform
|
|
18
|
-
} from
|
|
19
|
-
import Message from
|
|
20
|
-
import { MessagingDelegate } from
|
|
21
|
-
import { MessagingProposition } from
|
|
22
|
-
import { ContentCard } from
|
|
17
|
+
Platform,
|
|
18
|
+
} from "react-native";
|
|
19
|
+
import Message from "./models/Message";
|
|
20
|
+
import { MessagingDelegate } from "./models/MessagingDelegate";
|
|
21
|
+
import { MessagingProposition } from "./models/MessagingProposition";
|
|
22
|
+
import { ContentCard } from "./models/ContentCard";
|
|
23
|
+
import { PersonalizationSchema } from "./models/PersonalizationSchema";
|
|
24
|
+
import { ContentTemplate } from "./ui/types/Templates";
|
|
25
|
+
import {
|
|
26
|
+
InboxSettings,
|
|
27
|
+
SettingsPlacement,
|
|
28
|
+
} from "./ui/providers/InboxProvider";
|
|
23
29
|
|
|
24
30
|
export interface NativeMessagingModule {
|
|
25
31
|
extensionVersion: () => Promise<string>;
|
|
@@ -35,9 +41,20 @@ export interface NativeMessagingModule {
|
|
|
35
41
|
shouldSaveMessage: boolean
|
|
36
42
|
) => void;
|
|
37
43
|
updatePropositionsForSurfaces: (surfaces: string[]) => void;
|
|
38
|
-
trackContentCardDisplay: (
|
|
39
|
-
|
|
40
|
-
|
|
44
|
+
trackContentCardDisplay: (
|
|
45
|
+
proposition: MessagingProposition,
|
|
46
|
+
contentCard: ContentCard
|
|
47
|
+
) => void;
|
|
48
|
+
trackContentCardInteraction: (
|
|
49
|
+
proposition: MessagingProposition,
|
|
50
|
+
contentCard: ContentCard
|
|
51
|
+
) => void;
|
|
52
|
+
trackPropositionItem: (
|
|
53
|
+
itemId: string,
|
|
54
|
+
interaction: string | null,
|
|
55
|
+
eventType: number,
|
|
56
|
+
tokens: string[] | null
|
|
57
|
+
) => void;
|
|
41
58
|
}
|
|
42
59
|
|
|
43
60
|
const RCTAEPMessaging: NativeModule & NativeMessagingModule =
|
|
@@ -46,6 +63,134 @@ const RCTAEPMessaging: NativeModule & NativeMessagingModule =
|
|
|
46
63
|
declare var messagingDelegate: MessagingDelegate;
|
|
47
64
|
var messagingDelegate: MessagingDelegate;
|
|
48
65
|
|
|
66
|
+
function optString(map: Record<string, any> | undefined, key: string): string | undefined {
|
|
67
|
+
if (!map || typeof map !== 'object') return undefined;
|
|
68
|
+
const val = map[key] ?? map[key.toLowerCase()];
|
|
69
|
+
return typeof val === 'string' ? val : undefined;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function optInt(map: Record<string, any> | undefined, key: string, fallback: number): number {
|
|
73
|
+
if (!map || typeof map !== 'object') return fallback;
|
|
74
|
+
const val = map[key] ?? map[key.toLowerCase()];
|
|
75
|
+
if (typeof val === 'number' && !isNaN(val)) return val;
|
|
76
|
+
if (typeof val === 'string') {
|
|
77
|
+
const n = parseInt(val, 10);
|
|
78
|
+
return isNaN(n) ? fallback : n;
|
|
79
|
+
}
|
|
80
|
+
return fallback;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function optBoolean(map: Record<string, any> | undefined, key: string, fallback: boolean): boolean {
|
|
84
|
+
if (!map || typeof map !== 'object') return fallback;
|
|
85
|
+
const val = map[key] ?? map[key.toLowerCase()];
|
|
86
|
+
if (typeof val === 'boolean') return val;
|
|
87
|
+
if (val === 'true' || val === 1) return true;
|
|
88
|
+
if (val === 'false' || val === 0) return false;
|
|
89
|
+
return fallback;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function optTypedMap(map: Record<string, any> | undefined, key: string): Record<string, any> {
|
|
93
|
+
if (!map || typeof map !== 'object') return {};
|
|
94
|
+
const val = map[key] ?? map[key.toLowerCase()];
|
|
95
|
+
return val && typeof val === 'object' && !Array.isArray(val) ? val : {};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function createAepText(map: Record<string, any> | undefined, key: string): { content: string } | undefined {
|
|
99
|
+
const nested = optTypedMap(map, key);
|
|
100
|
+
const content = optString(nested, 'content') ?? optString(nested, 'txt');
|
|
101
|
+
return content !== undefined ? { content } : undefined;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function createAepColor(clrMap: Record<string, any>): { light: string; dark: string } | undefined {
|
|
105
|
+
if (!clrMap || typeof clrMap !== 'object') return undefined;
|
|
106
|
+
const light = optString(clrMap, 'light') ?? optString(clrMap, 'default') ?? '#FFFFFF';
|
|
107
|
+
const dark = optString(clrMap, 'dark') ?? light;
|
|
108
|
+
return { light, dark };
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function createAepImage(map: Record<string, any> | undefined): { url: string; darkUrl?: string } | undefined {
|
|
112
|
+
if (!map || typeof map !== 'object') return undefined;
|
|
113
|
+
const url = optString(map, 'url') ?? optString(map, 'src');
|
|
114
|
+
if (!url) return undefined;
|
|
115
|
+
const darkUrl = optString(map, 'darkUrl') ?? optString(map, 'dark');
|
|
116
|
+
return { url, darkUrl };
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function createAlignment(placement: string | undefined): SettingsPlacement {
|
|
120
|
+
const p = (placement ?? '').toLowerCase();
|
|
121
|
+
if (['topleft', 'topright', 'bottomleft', 'bottomright'].includes(p)) {
|
|
122
|
+
return p as SettingsPlacement;
|
|
123
|
+
}
|
|
124
|
+
return 'topleft';
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function createInboxSettingsFromContent(
|
|
128
|
+
contentMap: Record<string, any>,
|
|
129
|
+
activityId?: string
|
|
130
|
+
): InboxSettings {
|
|
131
|
+
const heading = createAepText(contentMap, 'heading') ?? createAepText(contentMap, 'Heading');
|
|
132
|
+
const layoutMap = optTypedMap(contentMap, 'layout');
|
|
133
|
+
const orientation = (optString(layoutMap, 'orientation') ?? 'vertical') as 'horizontal' | 'vertical';
|
|
134
|
+
const capacity = optInt(contentMap, 'capacity', 15);
|
|
135
|
+
|
|
136
|
+
if (!heading || !heading.content) {
|
|
137
|
+
throw new Error(
|
|
138
|
+
'Messaging.getInbox: inbox content is missing a valid heading (heading.content).'
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const emptyStateSettings = optTypedMap(contentMap, 'emptyStateSettings') ||
|
|
143
|
+
optTypedMap(contentMap, 'empty_state_settings') || {};
|
|
144
|
+
const emptyMessage = createAepText(emptyStateSettings, 'message') ?? createAepText(emptyStateSettings, 'Message');
|
|
145
|
+
const emptyImage = createAepImage(optTypedMap(emptyStateSettings, 'image'));
|
|
146
|
+
|
|
147
|
+
const unreadIndicator = optTypedMap(contentMap, 'unread_indicator') ||
|
|
148
|
+
optTypedMap(contentMap, 'unreadIndicator') || {};
|
|
149
|
+
const unreadBg = optTypedMap(unreadIndicator, 'unread_bg') || optTypedMap(unreadIndicator, 'unreadBg') || {};
|
|
150
|
+
const unreadBgClr = optTypedMap(unreadBg, 'clr') || {};
|
|
151
|
+
const unreadBgColor = createAepColor(unreadBgClr);
|
|
152
|
+
|
|
153
|
+
const unreadIcon = optTypedMap(unreadIndicator, 'unread_icon') || optTypedMap(unreadIndicator, 'unreadIcon') || {};
|
|
154
|
+
const placement = createAlignment(optString(unreadIndicator, 'placement') ?? optString(unreadIcon, 'placement'));
|
|
155
|
+
const unreadIconImage = createAepImage(optTypedMap(unreadIcon, 'image'));
|
|
156
|
+
|
|
157
|
+
const isUnreadEnabled = optBoolean(contentMap, 'isUnreadEnabled', true) ||
|
|
158
|
+
optBoolean(contentMap, 'is_unread_enabled', true);
|
|
159
|
+
|
|
160
|
+
const content: InboxSettings['content'] = {
|
|
161
|
+
heading,
|
|
162
|
+
layout: { orientation },
|
|
163
|
+
capacity,
|
|
164
|
+
emptyStateSettings: {
|
|
165
|
+
message: emptyMessage ?? { content: 'No Content Available' },
|
|
166
|
+
...(emptyImage && { image: emptyImage }),
|
|
167
|
+
},
|
|
168
|
+
isUnreadEnabled,
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
if (isUnreadEnabled && (unreadBgColor || unreadIconImage)) {
|
|
172
|
+
content.unread_indicator = {
|
|
173
|
+
unread_bg: {
|
|
174
|
+
clr: unreadBgColor ?? { light: '#FFF3E0', dark: '#2D1B0E' },
|
|
175
|
+
},
|
|
176
|
+
unread_icon: {
|
|
177
|
+
placement,
|
|
178
|
+
image: unreadIconImage ?? {
|
|
179
|
+
url: 'https://icons.veryicon.com/png/o/leisure/crisp-app-icon-library-v3/notification-5.png',
|
|
180
|
+
darkUrl: '',
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return {
|
|
187
|
+
...(activityId && { activityId }),
|
|
188
|
+
content,
|
|
189
|
+
showPagination: optBoolean(contentMap, 'showPagination', false) ||
|
|
190
|
+
optBoolean(contentMap, 'show_pagination', false),
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
|
|
49
194
|
class Messaging {
|
|
50
195
|
/**
|
|
51
196
|
* Returns the version of the AEPMessaging extension
|
|
@@ -106,29 +251,45 @@ class Messaging {
|
|
|
106
251
|
|
|
107
252
|
/**
|
|
108
253
|
* @deprecated Use PropositionItem.track(...) instead.
|
|
109
|
-
*/
|
|
110
|
-
static trackContentCardDisplay(
|
|
254
|
+
*/
|
|
255
|
+
static trackContentCardDisplay(
|
|
256
|
+
proposition: MessagingProposition,
|
|
257
|
+
contentCard: ContentCard
|
|
258
|
+
): void {
|
|
111
259
|
RCTAEPMessaging.trackContentCardDisplay(proposition, contentCard);
|
|
112
260
|
}
|
|
113
261
|
|
|
114
|
-
|
|
262
|
+
/**
|
|
115
263
|
* @deprecated Use PropositionItem.track(...) instead.
|
|
116
264
|
*/
|
|
117
|
-
static trackContentCardInteraction(
|
|
265
|
+
static trackContentCardInteraction(
|
|
266
|
+
proposition: MessagingProposition,
|
|
267
|
+
contentCard: ContentCard
|
|
268
|
+
): void {
|
|
118
269
|
RCTAEPMessaging.trackContentCardInteraction(proposition, contentCard);
|
|
119
270
|
}
|
|
120
271
|
|
|
121
272
|
/**
|
|
122
273
|
* Tracks interactions with a PropositionItem using the provided interaction and event type.
|
|
123
274
|
* This method is used internally by the PropositionItem.track() method.
|
|
124
|
-
*
|
|
275
|
+
*
|
|
125
276
|
* @param {string} itemId - The unique identifier of the PropositionItem
|
|
126
277
|
* @param {string | null} interaction - A custom string value to be recorded in the interaction
|
|
127
278
|
* @param {number} eventType - The MessagingEdgeEventType numeric value
|
|
128
279
|
* @param {string[] | null} tokens - Array containing the sub-item tokens for recording interaction
|
|
129
280
|
*/
|
|
130
|
-
static trackPropositionItem(
|
|
131
|
-
|
|
281
|
+
static trackPropositionItem(
|
|
282
|
+
itemId: string,
|
|
283
|
+
interaction: string | null,
|
|
284
|
+
eventType: number,
|
|
285
|
+
tokens: string[] | null
|
|
286
|
+
): void {
|
|
287
|
+
RCTAEPMessaging.trackPropositionItem(
|
|
288
|
+
itemId,
|
|
289
|
+
interaction,
|
|
290
|
+
eventType,
|
|
291
|
+
tokens
|
|
292
|
+
);
|
|
132
293
|
}
|
|
133
294
|
|
|
134
295
|
/**
|
|
@@ -140,17 +301,18 @@ class Messaging {
|
|
|
140
301
|
|
|
141
302
|
const eventEmitter = new NativeEventEmitter(RCTAEPMessaging);
|
|
142
303
|
|
|
143
|
-
eventEmitter.addListener(
|
|
304
|
+
eventEmitter.addListener("onShow", (message: Message) =>
|
|
144
305
|
messagingDelegate?.onShow?.(new Message(message))
|
|
145
306
|
);
|
|
146
307
|
|
|
147
|
-
eventEmitter.addListener(
|
|
308
|
+
eventEmitter.addListener("onDismiss", (message: Message) => {
|
|
148
309
|
const messageInstance = new Message(message);
|
|
149
310
|
messageInstance._clearJavascriptMessageHandlers();
|
|
311
|
+
messageInstance._clearJavascriptResultHandlers();
|
|
150
312
|
messagingDelegate?.onDismiss?.(messageInstance);
|
|
151
313
|
});
|
|
152
314
|
|
|
153
|
-
eventEmitter.addListener(
|
|
315
|
+
eventEmitter.addListener("shouldShowMessage", (message: Message) => {
|
|
154
316
|
const messageInstance = new Message(message);
|
|
155
317
|
const shouldShowMessage =
|
|
156
318
|
messagingDelegate?.shouldShowMessage?.(messageInstance) ?? true;
|
|
@@ -159,26 +321,34 @@ class Messaging {
|
|
|
159
321
|
RCTAEPMessaging.setMessageSettings(shouldShowMessage, shouldSaveMessage);
|
|
160
322
|
});
|
|
161
323
|
|
|
162
|
-
if (Platform.OS ===
|
|
163
|
-
eventEmitter.addListener(
|
|
164
|
-
|
|
324
|
+
if (Platform.OS === "ios") {
|
|
325
|
+
eventEmitter.addListener(
|
|
326
|
+
"urlLoaded",
|
|
327
|
+
(event: { url: string; message: Message }) =>
|
|
328
|
+
messagingDelegate?.urlLoaded?.(event.url, new Message(event.message))
|
|
165
329
|
);
|
|
166
330
|
}
|
|
167
331
|
|
|
168
|
-
if (Platform.OS ===
|
|
169
|
-
eventEmitter.addListener(
|
|
170
|
-
|
|
332
|
+
if (Platform.OS === "android") {
|
|
333
|
+
eventEmitter.addListener(
|
|
334
|
+
"onContentLoaded",
|
|
335
|
+
(event: { message: Message }) =>
|
|
336
|
+
messagingDelegate?.onContentLoaded?.(new Message(event.message))
|
|
171
337
|
);
|
|
172
338
|
}
|
|
173
339
|
|
|
174
340
|
RCTAEPMessaging.setMessagingDelegate();
|
|
175
341
|
|
|
176
342
|
return () => {
|
|
177
|
-
eventEmitter.removeAllListeners(
|
|
178
|
-
eventEmitter.removeAllListeners(
|
|
179
|
-
eventEmitter.removeAllListeners(
|
|
180
|
-
|
|
181
|
-
|
|
343
|
+
eventEmitter.removeAllListeners("onDismiss");
|
|
344
|
+
eventEmitter.removeAllListeners("onShow");
|
|
345
|
+
eventEmitter.removeAllListeners("shouldShowMessage");
|
|
346
|
+
if (Platform.OS === "ios") {
|
|
347
|
+
eventEmitter.removeAllListeners("urlLoaded");
|
|
348
|
+
}
|
|
349
|
+
if (Platform.OS === "android") {
|
|
350
|
+
eventEmitter.removeAllListeners("onContentLoaded");
|
|
351
|
+
}
|
|
182
352
|
};
|
|
183
353
|
}
|
|
184
354
|
|
|
@@ -200,8 +370,94 @@ class Messaging {
|
|
|
200
370
|
* Dispatches an event to fetch propositions for the provided surfaces from remote.
|
|
201
371
|
* @param surfaces A list of surface names to update
|
|
202
372
|
*/
|
|
203
|
-
static updatePropositionsForSurfaces(
|
|
204
|
-
|
|
373
|
+
static async updatePropositionsForSurfaces(
|
|
374
|
+
surfaces: string[]
|
|
375
|
+
): Promise<void> {
|
|
376
|
+
return await RCTAEPMessaging.updatePropositionsForSurfaces(surfaces);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* @experimental
|
|
381
|
+
* Retrieves the content card UI data for a given surface.
|
|
382
|
+
* @param surface The surface to get the content card UI data for
|
|
383
|
+
* @returns The content card UI data for the given surface
|
|
384
|
+
*/
|
|
385
|
+
static async getContentCardUI(surface: string): Promise<ContentTemplate[]> {
|
|
386
|
+
const messages = await Messaging.getPropositionsForSurfaces([surface]);
|
|
387
|
+
const propositions = messages[surface];
|
|
388
|
+
if (!propositions?.length) {
|
|
389
|
+
return [];
|
|
390
|
+
}
|
|
391
|
+
const contentCards = propositions
|
|
392
|
+
.flatMap((proposition) =>
|
|
393
|
+
proposition.items.filter(
|
|
394
|
+
(item) => item.schema === PersonalizationSchema.CONTENT_CARD
|
|
395
|
+
)
|
|
396
|
+
);
|
|
397
|
+
|
|
398
|
+
if (!contentCards?.length) {
|
|
399
|
+
return [];
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
return contentCards.map((card: any) => {
|
|
403
|
+
// Test: To mark first 2 cards as read, swap the two map lines above to add index, then replace isRead with:
|
|
404
|
+
// return contentCards.map((card: any, index: number) => {
|
|
405
|
+
const type = card.data?.meta?.adobe?.template ?? "SmallImage";
|
|
406
|
+
const isRead = card.data?.read ?? false;
|
|
407
|
+
// const isRead = card.data?.read ?? (index < 2);
|
|
408
|
+
return new ContentTemplate(card, type, isRead);
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* @experimental
|
|
415
|
+
* Loads inbox UI settings from the inbox proposition for the given surface.
|
|
416
|
+
* @throws {Error} When no propositions, no inbox proposition, or invalid inbox content is returned.
|
|
417
|
+
*/
|
|
418
|
+
static async getInbox(surface: string): Promise<InboxSettings> {
|
|
419
|
+
const propositionsMap = await Messaging.getPropositionsForSurfaces([surface]);
|
|
420
|
+
const propositions = propositionsMap[surface];
|
|
421
|
+
|
|
422
|
+
if (!propositions?.length) {
|
|
423
|
+
throw new Error(
|
|
424
|
+
`Messaging.getInbox: no propositions returned for surface "${surface}".`
|
|
425
|
+
);
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
const inboxPropositions = propositions.filter(
|
|
429
|
+
(p) =>
|
|
430
|
+
p.items?.length > 0 &&
|
|
431
|
+
(p.items[0].schema === PersonalizationSchema.INBOX ||
|
|
432
|
+
String(p.items[0].schema).includes('inbox'))
|
|
433
|
+
);
|
|
434
|
+
|
|
435
|
+
if (inboxPropositions.length === 0) {
|
|
436
|
+
throw new Error(
|
|
437
|
+
`Messaging.getInbox: no inbox proposition found for surface "${surface}".`
|
|
438
|
+
);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
const sortedByRank = [...inboxPropositions].sort(
|
|
442
|
+
(a, b) => ((b as any).rank ?? 0) - ((a as any).rank ?? 0)
|
|
443
|
+
);
|
|
444
|
+
const inboxProposition = sortedByRank[0];
|
|
445
|
+
const firstItem = inboxProposition.items[0];
|
|
446
|
+
const rawItem = firstItem as any;
|
|
447
|
+
|
|
448
|
+
const contentMap =
|
|
449
|
+
rawItem?.inboxSchemaData?.content ??
|
|
450
|
+
rawItem?.data?.inboxSchemaData?.content ??
|
|
451
|
+
rawItem?.data?.content;
|
|
452
|
+
|
|
453
|
+
if (!contentMap || typeof contentMap !== 'object') {
|
|
454
|
+
throw new Error(
|
|
455
|
+
`Messaging.getInbox: inbox proposition has no valid content configuration for surface "${surface}".`
|
|
456
|
+
);
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
const activityId = inboxProposition.scopeDetails?.activity?.id;
|
|
460
|
+
return createInboxSettingsFromContent(contentMap, activityId);
|
|
205
461
|
}
|
|
206
462
|
}
|
|
207
463
|
|
package/src/index.ts
CHANGED
|
@@ -11,7 +11,6 @@ governing permissions and limitations under the License.
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import Messaging from './Messaging';
|
|
14
|
-
import { ContentCard, ContentCardData } from './models/ContentCard';
|
|
15
14
|
|
|
16
15
|
import { InAppMessage } from './models/InAppMessage';
|
|
17
16
|
import { HTMLProposition, HTMLPropositionData } from './models/HTMLProposition';
|
|
@@ -26,11 +25,12 @@ import { PersonalizationSchema } from './models/PersonalizationSchema';
|
|
|
26
25
|
import { PropositionItem, PropositionItemData } from './models/PropositionItem';
|
|
27
26
|
import { Activity, Characteristics } from './models/ScopeDetails';
|
|
28
27
|
|
|
28
|
+
export * from './models/ContentCard';
|
|
29
|
+
export * from './ui';
|
|
30
|
+
|
|
29
31
|
export {
|
|
30
32
|
Activity,
|
|
31
33
|
Characteristics,
|
|
32
|
-
ContentCard,
|
|
33
|
-
ContentCardData,
|
|
34
34
|
InAppMessage,
|
|
35
35
|
Messaging,
|
|
36
36
|
Message,
|
|
@@ -13,46 +13,71 @@
|
|
|
13
13
|
import { PersonalizationSchema } from './PersonalizationSchema';
|
|
14
14
|
import { PropositionItem, PropositionItemData } from './PropositionItem';
|
|
15
15
|
|
|
16
|
-
type ContentCardTemplate = 'SmallImage';
|
|
17
|
-
type DismissButtonStyle = 'circle' | 'none' | 'simple';
|
|
16
|
+
export type ContentCardTemplate = 'SmallImage' | 'LargeImage' | 'ImageOnly';
|
|
17
|
+
export type DismissButtonStyle = 'circle' | 'none' | 'simple';
|
|
18
|
+
|
|
19
|
+
export interface ContentCardButton {
|
|
20
|
+
readonly interactId: string;
|
|
21
|
+
readonly actionUrl?: string;
|
|
22
|
+
readonly id?: string;
|
|
23
|
+
readonly text: {
|
|
24
|
+
readonly content: string;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface ContentCardContent {
|
|
29
|
+
readonly image?: {
|
|
30
|
+
readonly alt?: string;
|
|
31
|
+
readonly url: string;
|
|
32
|
+
readonly darkUrl?: string;
|
|
33
|
+
};
|
|
34
|
+
readonly buttons?: readonly ContentCardButton[];
|
|
35
|
+
readonly dismissBtn?: {
|
|
36
|
+
readonly style: DismissButtonStyle;
|
|
37
|
+
};
|
|
38
|
+
readonly actionUrl?: string;
|
|
39
|
+
readonly body?: {
|
|
40
|
+
readonly content: string;
|
|
41
|
+
};
|
|
42
|
+
readonly title: {
|
|
43
|
+
readonly content: string;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export type ImageOnlyContent = Pick<
|
|
48
|
+
ContentCardContent,
|
|
49
|
+
'image' | 'dismissBtn' | 'actionUrl'
|
|
50
|
+
>;
|
|
51
|
+
|
|
52
|
+
export type LargeImageContentData = ContentCardContent;
|
|
53
|
+
|
|
54
|
+
export type SmallImageContentData = ContentCardContent;
|
|
55
|
+
|
|
56
|
+
export interface ContentCardMeta {
|
|
57
|
+
[key: string]: any;
|
|
58
|
+
adobe: { template: ContentCardTemplate };
|
|
59
|
+
surface?: string;
|
|
60
|
+
}
|
|
18
61
|
|
|
19
62
|
export interface ContentCardData extends PropositionItemData {
|
|
20
63
|
id: string;
|
|
64
|
+
schema: PersonalizationSchema.CONTENT_CARD;
|
|
21
65
|
data: {
|
|
22
66
|
contentType: 'application/json';
|
|
23
67
|
expiryDate: number;
|
|
24
68
|
publishedDate: number;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
body: { content: string };
|
|
29
|
-
title: { content: string };
|
|
30
|
-
buttons: Array<{
|
|
31
|
-
actionUrl: string;
|
|
32
|
-
id: string;
|
|
33
|
-
text: { content: string };
|
|
34
|
-
interactId: string;
|
|
35
|
-
}>;
|
|
36
|
-
image: { alt: string; url: string };
|
|
37
|
-
dismissBtn: { style: DismissButtonStyle };
|
|
38
|
-
};
|
|
39
|
-
meta: {
|
|
40
|
-
[key: string]: any;
|
|
41
|
-
adobe: { template: ContentCardTemplate };
|
|
42
|
-
dismissState: boolean;
|
|
43
|
-
readState: boolean;
|
|
44
|
-
surface: string;
|
|
45
|
-
};
|
|
69
|
+
meta: ContentCardMeta;
|
|
70
|
+
content: SmallImageContentData | LargeImageContentData | ImageOnlyContent;
|
|
46
71
|
};
|
|
47
|
-
schema: PersonalizationSchema.CONTENT_CARD;
|
|
48
72
|
}
|
|
49
73
|
|
|
50
74
|
export class ContentCard extends PropositionItem {
|
|
51
|
-
|
|
75
|
+
data: ContentCardData['data'];
|
|
76
|
+
isRead: boolean = false;
|
|
52
77
|
|
|
53
|
-
constructor(contentCardData: ContentCardData) {
|
|
78
|
+
constructor(contentCardData: ContentCardData, isRead: boolean = false) {
|
|
54
79
|
super(contentCardData);
|
|
55
80
|
this.data = contentCardData.data;
|
|
81
|
+
this.isRead = isRead;
|
|
56
82
|
}
|
|
57
|
-
|
|
58
83
|
}
|
|
@@ -21,7 +21,7 @@ export interface HTMLPropositionData extends PropositionItemData {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export class HTMLProposition extends PropositionItem {
|
|
24
|
-
|
|
24
|
+
data: HTMLPropositionData['data'];
|
|
25
25
|
|
|
26
26
|
constructor(htmlData: HTMLPropositionData) {
|
|
27
27
|
super(htmlData);
|
|
@@ -21,7 +21,7 @@ export interface JSONPropositionData extends PropositionItemData {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export class JSONPropositionItem extends PropositionItem {
|
|
24
|
-
|
|
24
|
+
data: JSONPropositionData['data'];
|
|
25
25
|
|
|
26
26
|
constructor(jsonData: JSONPropositionData) {
|
|
27
27
|
super(jsonData);
|
package/src/models/Message.ts
CHANGED
|
@@ -17,6 +17,11 @@ const RCTAEPMessaging = NativeModules.AEPMessaging;
|
|
|
17
17
|
// Registery to store inAppMessage callbacks for each message in Message.handleJavascriptMessage
|
|
18
18
|
// Record - {messageId : {handlerName : callback}}
|
|
19
19
|
const jsMessageHandlers: Record<string, Record<string, (content: string) => void>> = {};
|
|
20
|
+
|
|
21
|
+
// Registery to store inAppMessage result callbacks for each message in Message.evaluateJavascript
|
|
22
|
+
// Record - {messageId : {javascriptString : callback}}
|
|
23
|
+
const jsResultHandlers: Record<string, Record<string, (result: string) => void>> = {};
|
|
24
|
+
|
|
20
25
|
const handleJSMessageEventEmitter = new NativeEventEmitter(RCTAEPMessaging);
|
|
21
26
|
|
|
22
27
|
// invokes the callback registered in Message.handleJavascriptMessage with the content received from the inAppMessage webview
|
|
@@ -27,6 +32,15 @@ handleJSMessageEventEmitter.addListener('onJavascriptMessage', (event) => {
|
|
|
27
32
|
}
|
|
28
33
|
});
|
|
29
34
|
|
|
35
|
+
handleJSMessageEventEmitter.addListener('onJavascriptResult', (event) => {
|
|
36
|
+
const {messageId, javascriptString, result} = event;
|
|
37
|
+
if (jsResultHandlers[messageId] && jsResultHandlers[messageId][javascriptString]) {
|
|
38
|
+
// Convert result to string to maintain API parity
|
|
39
|
+
const resultString = result == null ? '' : String(result);
|
|
40
|
+
jsResultHandlers[messageId][javascriptString](resultString);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
30
44
|
class Message {
|
|
31
45
|
id: string;
|
|
32
46
|
autoTrack: boolean;
|
|
@@ -117,6 +131,32 @@ class Message {
|
|
|
117
131
|
RCTAEPMessaging.handleJavascriptMessage(this.id, handlerName);
|
|
118
132
|
}
|
|
119
133
|
|
|
134
|
+
/**
|
|
135
|
+
* Asynchronously evaluates the specified JavaScript string in the context of the message's WebView.
|
|
136
|
+
* @param {string} javascriptString: The JavaScript string to evaluate.
|
|
137
|
+
* @param {function} callback: A callback to be invoked when the script execution completes with the result of the execution.
|
|
138
|
+
*/
|
|
139
|
+
evaluateJavascript(javascriptString: string, callback: (result: string) => void) {
|
|
140
|
+
// validate parameters
|
|
141
|
+
if (!javascriptString) {
|
|
142
|
+
console.warn('[AEP Messaging] evaluateJavascript: javascriptString is required');
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (typeof callback !== 'function') {
|
|
147
|
+
console.warn('[AEP Messaging] evaluateJavascript: callback must be a function');
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// cache the callback
|
|
152
|
+
if (!jsResultHandlers[this.id]) {
|
|
153
|
+
jsResultHandlers[this.id] = {};
|
|
154
|
+
}
|
|
155
|
+
jsResultHandlers[this.id][javascriptString] = callback;
|
|
156
|
+
|
|
157
|
+
RCTAEPMessaging.evaluateJavascript(this.id, javascriptString);
|
|
158
|
+
}
|
|
159
|
+
|
|
120
160
|
/**
|
|
121
161
|
* @internal - For internal use only.
|
|
122
162
|
* Clears all the javascript message handlers for the message.
|
|
@@ -126,6 +166,16 @@ class Message {
|
|
|
126
166
|
_clearJavascriptMessageHandlers() {
|
|
127
167
|
delete jsMessageHandlers[this.id];
|
|
128
168
|
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* @internal - For internal use only.
|
|
172
|
+
* Clears all the javascript result handlers for the message.
|
|
173
|
+
* This function must be called if the callbacks registered in evaluateJavascript are no longer needed.
|
|
174
|
+
* Failure to call this function may lead to memory leaks.
|
|
175
|
+
*/
|
|
176
|
+
_clearJavascriptResultHandlers() {
|
|
177
|
+
delete jsResultHandlers[this.id];
|
|
178
|
+
}
|
|
129
179
|
}
|
|
130
180
|
|
|
131
181
|
export default Message;
|
|
@@ -15,6 +15,7 @@ export enum PersonalizationSchema {
|
|
|
15
15
|
DEFAULT_CONTENT = 'https://ns.adobe.com/personalization/default-content-item',
|
|
16
16
|
HTML_CONTENT = 'https://ns.adobe.com/personalization/html-content-item',
|
|
17
17
|
IN_APP = 'https://ns.adobe.com/personalization/message/in-app',
|
|
18
|
+
INBOX = 'https://ns.adobe.com/personalization/message/inbox',
|
|
18
19
|
JSON_CONTENT = 'https://ns.adobe.com/personalization/json-content-item',
|
|
19
20
|
NATIVE_ALERT = 'https://ns.adobe.com/personalization/message/native-alert',
|
|
20
21
|
RULESET_ITEM = 'https://ns.adobe.com/personalization/ruleset-item'
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2026 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the
|
|
4
|
+
"License"); you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
|
|
7
|
+
or agreed to in writing, software distributed under the License is
|
|
8
|
+
distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF
|
|
9
|
+
ANY KIND, either express or implied. See the License for the specific
|
|
10
|
+
language governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export * from './ContentCard';
|
|
14
|
+
export * from './InAppMessage';
|
|
15
|
+
export * from './JSONProposition';
|
|
16
|
+
export * from './Message';
|
|
17
|
+
export * from './MessagingDelegate';
|
|
18
|
+
export * from './MessagingEdgeEventType';
|
|
19
|
+
export * from './MessagingProposition';
|
|
20
|
+
export * from './MessagingPropositionItem';
|
|
21
|
+
export * from './PersonalizationSchema';
|
|
22
|
+
export * from './ScopeDetails';
|