@@ -9,7 +9,8 @@ import { IterableEmbeddedNotification } from './IterableEmbeddedNotification';
99/**
1010 * The props for the IterableEmbeddedView component.
1111 */
12- export interface IterableEmbeddedViewProps extends IterableEmbeddedComponentProps {
12+ export interface IterableEmbeddedViewProps
13+ extends IterableEmbeddedComponentProps {
1314 /** The type of view to render. */
1415 viewType : IterableEmbeddedViewType ;
1516}
@@ -23,45 +24,62 @@ export interface IterableEmbeddedViewProps extends IterableEmbeddedComponentProp
2324 * @param onMessageClick - The function to call when the message is clicked.
2425 * @returns The IterableEmbeddedView component.
2526 *
26- * This component is used to render pre-created, customizable message displays
27- * included with Iterables RN SDK: cards, banners, and notifications.
27+ * This component is used to render the following pre-created, customizable
28+ * message displays included with Iterables RN SDK: cards, banners, and
29+ * notifications.
2830 *
2931 * @example
3032 * ```tsx
31- * // See `IterableEmbeddedViewType`` for available view types.
33+ * import {
34+ * IterableAction,
35+ * IterableEmbeddedView,
36+ * IterableEmbeddedViewType,
37+ * type IterableEmbeddedMessage,
38+ * type IterableEmbeddedMessageElementsButton,
39+ * } from '@iterable/react-native-sdk';
40+ *
41+ * // See `IterableEmbeddedViewType` for available view types.
3242 * const viewType = IterableEmbeddedViewType.Card;
3343 *
34- * // The message object that will be rendered.
35- * // You can retrieve messages by calling `Iterable.embeddedManager.getMessages(IDS)`
36- * const message = {
44+ * // Messages usually come from the embedded manager. `placementIds` is `number[] | null`
45+ * // (use `null` to load messages for all placements), for example:
46+ * // Iterable.embeddedManager.getMessages([101, 102]).then((messages) => { ... });
47+ * const message: IterableEmbeddedMessage = {
3748 * metadata: {
3849 * messageId: 'test-message-123',
50+ * placementId: 101,
3951 * campaignId: 123456,
40- * placementId: 'test-placement',
4152 * },
4253 * elements: {
4354 * title: 'Test Title',
4455 * body: 'Test Body',
4556 * buttons: [
46- * { id: 'button-1', label: 'Button 1', action: 'button-1-action' },
47- * { id: 'button-2', label: 'Button 2', action: 'button-2-action' },
57+ * {
58+ * id: 'button-1',
59+ * title: 'Button 1',
60+ * action: new IterableAction('openUrl', 'https://example.com/one'),
61+ * },
62+ * {
63+ * id: 'button-2',
64+ * title: 'Button 2',
65+ * action: new IterableAction('openUrl', 'https://example.com/two'),
66+ * },
4867 * ],
4968 * },
5069 * };
5170 *
52- * // The config for the IterableEmbeddedView component, most likely used to style the view .
71+ * // The config is used to style the component .
5372 * // See `IterableEmbeddedViewConfig` for available config options.
5473 * const config = { backgroundColor: '#FFFFFF', borderRadius: 8 };
5574 *
56- * // A callback that will be called when a button is clicked.
57- * // General click handling is handled by the SDK; This is only for custom logic .
58- * const onButtonClick = () => {
59- * console.log('Button clicked');
75+ * // `onButtonClick` will be called when a button is clicked.
76+ * // This callback allows you to add custom logic in addition to the SDK's default handling .
77+ * const onButtonClick = (button: IterableEmbeddedMessageElementsButton ) => {
78+ * console.log('Button clicked', button.id, button.title, button.action );
6079 * };
6180 *
62- * // A callback that will be called when the message is clicked.
63- * // This is not called when a button is clicked.
64- * // If a default action is set, this is what will be called.
81+ * // `onMessageClick` will be called when the message is clicked anywhere outside of a button.
82+ * // If a default action is set, it will be handled prior to this callback.
6583 * const onMessageClick = () => {
6684 * console.log('Message clicked');
6785 * };
0 commit comments