@@ -9,12 +9,12 @@ The `@sirenapp/react-native-inbox` sdk is a comprehensive and customizable React
99You can install the react sdk from npm
1010
1111``` bash
12- npm @sirenapp/react-native-inbox
12+ npm install @sirenapp/react-native-inbox
1313```
1414or from yarn
1515
1616``` bash
17- yarn @sirenapp/react-native-inbox
17+ yarn add @sirenapp/react-native-inbox
1818```
1919
2020## 2. Configuration
@@ -51,7 +51,7 @@ Below are optional props available for the icon component:
5151Prop | Description | Type | Default value |
5252--- | --- | --- | --- |
5353theme | Object for custom themes | Theme | {} |
54- customStyles | Object for custom styling | StyleProps | {} |
54+ customStyles | Object for custom styling | CustomStyleProps | {} |
5555notificationIcon | Option to use custom notification icon | JSX Element | null |
5656darkMode | Toggle to enable dark mode | boolean | false |
5757onError | Callback for handling errors | (error: SirenErrorType)=> void | null |
@@ -80,7 +80,7 @@ Here are the available theme options:
8080Here are the custom style options for the notification icon:
8181``` js
8282
83- type StyleProps = {
83+ type CustomStyleProps = {
8484 notificationIcon?: {
8585 size?: number,
8686 };
@@ -109,17 +109,14 @@ Below are optional props available for the inbox component:
109109Prop | Description | Type | Default value |
110110--- | --- | --- | --- |
111111theme | Object for custom themes | Theme | {} |
112- customStyles | Object for custom styling | StyleProps | {} |
113- title | Title of the notification inbox | string | "Notifications" |
114- hideHeader | Toggle to hide or show the header section | boolean | false |
115- hideClearAll | Toggle to hide or show the clear all button | boolean | false |
112+ customStyles | Object for custom styling | CustomStyleProps | {} |
116113darkMode | Toggle to enable dark mode| boolean | false |
117114itemsPerFetch | Number of notifications fetch per api request (have a max cap of 50) | number | 20 |
118- cardProps | Props for customizing the notification cards | { hideAvatar: boolean } | { hideAvatar: false } |
119- customNotificationCard | Function for rendering custom notification cards | (notification)=> JSX Element | null |
120- onNotificationCardClick | Custom click handler for notification cards | (notification)=> void | ()=>null |
121- listEmptyComponent | Custom component for empty notification list | JSX Element | null |
122- customHeader | Custom header component | JSX Element | null |
115+ cardProps | Props for customizing the card | CardProps | { hideAvatar: false, disableAutoMarkAsRead: false, hideDelete: false, deleteIcon: JSX.Element, onAvatarClick: ()=> null, hideMediaThumbnailL: false, onMediaThumbnailClick: ()=> null } |
116+ customCard | Function for rendering custom card | (notification)=> JSX Element | null |
117+ onCardClick | Custom click handler for card | (notification)=> void | ()=>null |
118+ listEmptyComponent | Custom component for empty list | JSX Element | null |
119+ headerProps | Props for customizing the header | HeaderProps | { title: "Notifications", hideHeader: false, hideClearAll: false, customHeader: null, showBackButton : false , backButton: null, onBackPress: ()=> null } |
123120customFooter | Custom footer component | JSX Element | null |
124121customLoader | Custom component to display the initial loading state| JSX Element | null |
125122customErrorWindow | Custom error window | JSX Element | null |
@@ -154,7 +151,6 @@ Here are the available theme options:
154151 titleColor?: string;
155152 headerActionColor?: string;
156153 borderColor?: string;
157- borderWidth?: string;
158154 };
159155 windowContainer?: {
160156 background?: string;
@@ -163,8 +159,8 @@ Here are the available theme options:
163159 borderColor?: string;
164160 background?: string;
165161 titleColor?: string;
162+ subTitleColor?: string;
166163 descriptionColor?: string;
167- dateColor?: string;
168164 };
169165 }
170166```
@@ -174,10 +170,7 @@ Here are the available theme options:
174170Here are the custom style options for the notification inbox:
175171
176172``` js
177- export type StyleProps = {
178- notificationIcon ?: {
179- size ?: number ;
180- };
173+ type CustomStyleProps = {
181174 window ?: {
182175 width?: DimensionValue;
183176 height?: DimensionValue;
@@ -186,6 +179,8 @@ Here are the custom style options for the notification inbox:
186179 height?: number;
187180 titleFontWeight?: TextStyle[' fontWeight' ];
188181 titleSize?: number;
182+ borderWidth?: string;
183+ titlePadding?: number;
189184 }
190185 windowContainer?: {
191186 padding?: number;
@@ -196,26 +191,48 @@ Here are the custom style options for the notification inbox:
196191 avatarSize?: number;
197192 titleFontWeight?: TextStyle[' fontWeight' ];
198193 titleSize?: number;
194+ subtitleFontWeight?: TextStyle[' fontWeight' ];
195+ subtitleSize?: number
196+ descriptionFontWeight?: TextStyle[' fontWeight' ];
199197 descriptionSize?: number;
200198 dateSize?: number;
201199 };
202- badgeStyle?: {
203- size?: number;
204- textSize?: number;
205- top?: number;
206- right?: number;
207- };
208200 deleteIcon?: {
209201 size?: number
210202 };
211- dateIcon ?: {
203+ timerIcon ?: {
212204 size?: number
213205 };
214206 clearAllIcon?: {
215207 size?: number
216208 };
217209 };
218210```
211+ #### CardProps
212+ ``` js
213+ type CardProps = {
214+ hideAvatar?: boolean;
215+ onAvatarClick?: (notification : NotificationDataType ) => void ;
216+ disableAutoMarkAsRead?: boolean;
217+ deleteIcon?: JSX .Element ;
218+ hideDelete?: boolean;
219+ hideMediaThumbnail?: boolean;
220+ onMediaThumbnailClick?: (notification : NotificationDataType ) => void ;
221+ };
222+ ```
223+
224+ #### HeaderProps
225+ ``` js
226+ type HeaderProps = {
227+ title?: string;
228+ hideHeader?: boolean;
229+ hideClearAll?: boolean;
230+ customHeader?: JSX .Element | null ;
231+ showBackButton?: boolean;
232+ backButton?: JSX .Element ;
233+ onBackPress?: () => void ;
234+ };
235+ ```
219236
220237## 3. Hooks
221238
@@ -225,14 +242,10 @@ Here are the custom style options for the notification inbox:
225242import { useSiren } from ' @sirenapp/react-native-inbox' ;
226243
227244function MyComponent () {
228- const { markAsRead , deleteNotification } = useSiren ();
245+ const { markAsReadById , deleteById } = useSiren ();
229246
230247 function handleMarkAsRead (id ) {
231- markAsRead (id);
232- }
233-
234- function handleDeleteNotification (id ) {
235- deleteNotification (id);
248+ markAsReadById (id);
236249 }
237250
238251 return (
@@ -244,23 +257,11 @@ function MyComponent() {
244257
245258Functions | Parameters | Type | Description |
246259----------|------------|-------|------------|
247- markNotificationsAsReadByDate | startDate | ISO date string | Sets the read status of notifications to true until the given date |
248- markAsRead | id | string | Set read status of a notification to true |
249- deleteNotification | id | string | Delete a notification by id |
250- deleteNotificationsByDate | startDate | ISO date string | Delete all notifications until given date |
251- markNotificationsAsViewed | startDate | ISO date string |Sets the viewed status of notifications to true until the given date |
252-
253- ## 4. Error codes
254- Given below are all possible error codes thrown by sdk:
255-
256- Error code | Description |
257- --- | --- |
258- INVALID_TOKEN | The token passed in the provider is invalid |
259- INVALID_RECIPIENT_ID | The recipient id passed in the provider is invalid |
260- TOKEN_VERIFICATION_FAILED | Verification of the given tokens has failed |
261- GENERIC_API_ERROR | Occurrence of an unexpected api error |
262- OUTSIDE_SIREN_CONTEXT | Attempting to invoke the functions outside the siren inbox context |
263- MISSING_PARAMETER | The required parameter is missing |
260+ markAsReadByDate | startDate | ISO date string | Sets the read status of notifications to true until the given date |
261+ markAsReadById | id | string | Set read status of a notification to true |
262+ deleteById | id | string | Delete a notification by id |
263+ deleteByDate | startDate | ISO date string | Delete all notifications until given date |
264+ markAllAsViewed | startDate | ISO date string |Sets the viewed status of notifications to true until the given date |
264265
265266## Example
266267Here's a basic example to help you get started
@@ -294,10 +295,9 @@ function MyContainer(): React.JSX.Element {
294295 darkMode= {false }
295296 / >
296297 < SirenInbox
297- title= " Notifications"
298298 hideHeader= {false }
299299 darkMode= {false }
300- cardProps= {{hideAvatar: false }}
300+ cardProps= {{hideAvatar: false , disableAutoMarkAsRead : false }}
301301 / >
302302 < / View>
303303 );
0 commit comments