react-native-webengage-inbox
Version:
React-Native WebEngage Personalization
249 lines (219 loc) • 8.04 kB
TypeScript
export interface WENotificationMessage {
id?: string;
variationUtmDataDto?: unknown[];
message?: string;
templateMode?: boolean;
androidDetails?: {
expandableDetails?: {
style?: string;
ratingScale?: number;
message?: string;
};
advancedCustomizations?: Record<string, unknown>;
};
iosDetails?: {
expandableDetails?: {
style?: string;
ratingScale?: number;
message?: string;
};
secondaryCta?: {
id?: string;
name?: string;
ctaDetails?: unknown[];
};
advancedCustomizations?: Record<string, unknown>;
};
variationType?: string;
title?: string;
experimentVariationStatus?: string;
layoutType?: string;
customizations?: {
richTitle?: string;
richMessage?: string;
backgroundColor?: string;
};
name?: string;
sampling?: number;
}
export interface WENotificationItem {
creationTime?: string;
channelType?: string;
childExperimentId?: string;
experimentId?: string;
scope?: string;
category?: string;
message?: WENotificationMessage;
status?: "READ" | "UNREAD";
variationId?: string;
childVariationId?: string;
}
export interface WENotificationListResponse {
messageList: WENotificationItem[];
hasNext: boolean;
}
export interface WEError {
error: string;
}
declare module "react-native" {
interface NativeModulesStatic {
WEInboxReact: {
/**
* Initialize WebEngage Notification Inbox
* @description Must be called before using any other inbox methods
*/
initWENotificationInbox(): void;
/**
* Get notification list with optional offset
* @param offset WENotificationItem for pagination offset (internally stringified to JSON)
* @param callback Callback function with result and error
*/
getNotificationList(offset: WENotificationItem | null, callback: (result: { messageList: string; hasNext: boolean } | null, error: WEError | null) => void): void;
/**
* Get notification count for user
* @param callback Callback function with count and error
*/
getNotificationCount(callback: (result: string | null, error: WEError | null) => void): void;
/**
* Mark notification as read
* @param notificationItem Notification item to mark as read
*/
markRead(notificationItem: WENotificationItem): void;
/**
* Mark notification as unread
* @param notificationItem Notification item to mark as unread
*/
markUnread(notificationItem: WENotificationItem): void;
/**
* Track click event on notification
* @param notificationItem Notification item that was clicked
*/
trackClick(notificationItem: WENotificationItem): void;
/**
* Track view event for notification
* @param notificationItem Notification item that was viewed
*/
trackView(notificationItem: WENotificationItem): void;
/**
* Mark notification for deletion
* @param notificationItem Notification item to delete
*/
markDelete(notificationItem: WENotificationItem): void;
/**
* Mark all notifications as read
* @param notificationList Array of notifications to mark as read
*/
readAll(notificationList: WENotificationItem[]): void;
/**
* Mark all notifications as unread
* @param notificationList Array of notifications to mark as unread
*/
unReadAll(notificationList: WENotificationItem[]): void;
/**
* Delete all notifications
* @param notificationList Array of notifications to delete
*/
deleteAll(notificationList: WENotificationItem[]): void;
/**
* Reset notification count
* @description Called when notification icon is clicked
*/
onNotificationIconClick(): void;
};
}
}
// TurboModule interface for new architecture
export interface NativeWEInboxModule {
/** Initialize WebEngage Notification Inbox */
initWENotificationInbox(): void;
/** Get notification list (offset internally stringified to JSON) */
getNotificationList(offset: WENotificationItem | null, callback: (result: { messageList: string; hasNext: boolean } | null, error: WEError | null) => void): void;
/** Get notification count */
getNotificationCount(callback: (result: string | null, error: WEError | null) => void): void;
/** Mark notification as read */
markRead(notificationItem: WENotificationItem): void;
/** Mark notification as unread */
markUnread(notificationItem: WENotificationItem): void;
/** Track click event */
trackClick(notificationItem: WENotificationItem): void;
/** Track view event */
trackView(notificationItem: WENotificationItem): void;
/** Mark notification for deletion */
markDelete(notificationItem: WENotificationItem): void;
/** Mark all as read */
readAll(notificationList: WENotificationItem[]): void;
/** Mark all as unread */
unReadAll(notificationList: WENotificationItem[]): void;
/** Delete all notifications */
deleteAll(notificationList: WENotificationItem[]): void;
/** Reset notification count */
onNotificationIconClick(): void;
}
declare module "react-native-webengage-inbox" {
/**
* Initializes the WebEngage Notification Inbox.
* This function should be called before using other inbox functions.
*/
export function initWENotificationInbox(): void;
/**
* Retrieves the list of notifications.
* @param offset - Optional WENotificationItem to use as offset for pagination.
* @returns {Promise<WENotificationListResponse>} A promise that resolves to the list of notifications.
*/
export function getNotificationList(offset?: WENotificationItem | null): Promise<WENotificationListResponse>;
/**
* Retrieves the notification count for the user.
* @returns {Promise<string>} A promise that resolves to the notification count.
*/
export function getNotificationCount(): Promise<string>;
/**
* Marks a notification as read.
* @param notificationItem - The notification item to be marked as read.
*/
export function markRead(notificationItem: WENotificationItem): void;
/**
* Marks a notification as unread.
* @param notificationItem - The notification item to be marked as unread.
*/
export function markUnread(notificationItem: WENotificationItem): void;
/**
* Tracks a click event on a notification.
* @param notificationItem - The notification item that was clicked.
*/
export function trackClick(notificationItem: WENotificationItem): void;
/**
* Tracks a view event for a notification.
* @param notificationItem - The notification item that was viewed.
*/
export function trackView(notificationItem: WENotificationItem): void;
/**
* Marks a notification for deletion.
* @param notificationItem - The notification item to be deleted.
*/
export function markDelete(notificationItem: WENotificationItem): void;
/**
* Marks all notifications in the provided list as read.
* @param list - The list of notifications to be marked as read.
*/
export function readAll(list: WENotificationItem[]): void;
/**
* Marks all notifications in the provided list as unread.
* @param list - The list of notifications to be marked as unread.
*/
export function unReadAll(list: WENotificationItem[]): void;
/**
* Deletes all notifications in the provided list.
* @param list - The list of notifications to be deleted.
*/
export function deleteAll(list: WENotificationItem[]): void;
/**
* Resets the notification count.
* This function should be called to reset the count displayed in the UI.
*/
export function resetNotificationCount(): void;
/**
* Enables developer mode for debugging purposes.
* This mode can provide additional logging and information during development.
*/
export function enableDevMode(): void;
}