@@ -51,7 +51,7 @@ Below are optional props available for the icon component:
51
51
Prop | Description | Type | Default value |
52
52
--- | --- | --- | --- |
53
53
theme | Object for custom themes | Theme | {} |
54
- customStyles | Object for custom styling | StyleProps | {} |
54
+ customStyles | Object for custom styling | CustomStyleProps | {} |
55
55
notificationIcon | Option to use custom notification icon | JSX Element | null |
56
56
darkMode | Toggle to enable dark mode | boolean | false |
57
57
onError | Callback for handling errors | (error: SirenErrorType)=> void | null |
@@ -80,7 +80,7 @@ Here are the available theme options:
80
80
Here are the custom style options for the notification icon:
81
81
``` js
82
82
83
- type StyleProps = {
83
+ type CustomStyleProps = {
84
84
notificationIcon?: {
85
85
size?: number,
86
86
};
@@ -109,14 +109,14 @@ Below are optional props available for the inbox component:
109
109
Prop | Description | Type | Default value |
110
110
--- | --- | --- | --- |
111
111
theme | Object for custom themes | Theme | {} |
112
- customStyles | Object for custom styling | StyleProps | {} |
112
+ customStyles | Object for custom styling | CustomStyleProps | {} |
113
113
darkMode | Toggle to enable dark mode| boolean | false |
114
114
itemsPerFetch | Number of notifications fetch per api request (have a max cap of 50) | number | 20 |
115
- cardProps | Props for customizing the notification cards | CardProps | { hideAvatar: false, disableAutoMarkAsRead: false, hideDelete: false } |
116
- customNotificationCard | Function for rendering custom notification cards | (notification)=> JSX Element | null |
117
- onNotificationCardClick | Custom click handler for notification cards | (notification)=> void | ()=>null |
118
- listEmptyComponent | Custom component for empty notification list | JSX Element | null |
119
- inboxHeaderProps | Props for customizing the header | InboxHeaderProps | { title: "Notifications", hideHeader: false, hideClearAll: false, customHeader: null, showBackButton: false , backButton: null, onBackPress: ()=> null } |
115
+ cardProps | Props for customizing the card | CardProps | { hideAvatar: false, disableAutoMarkAsRead: false, hideDelete: false, deleteIcon: JSX.Element, onAvatarClick: ()=> 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 } |
120
120
customFooter | Custom footer component | JSX Element | null |
121
121
customLoader | Custom component to display the initial loading state| JSX Element | null |
122
122
customErrorWindow | Custom error window | JSX Element | null |
@@ -151,7 +151,6 @@ Here are the available theme options:
151
151
titleColor?: string;
152
152
headerActionColor?: string;
153
153
borderColor?: string;
154
- borderWidth?: string;
155
154
};
156
155
windowContainer?: {
157
156
background?: string;
@@ -160,8 +159,8 @@ Here are the available theme options:
160
159
borderColor?: string;
161
160
background?: string;
162
161
titleColor?: string;
162
+ subTitleColor?: string;
163
163
descriptionColor?: string;
164
- dateColor?: string;
165
164
};
166
165
}
167
166
```
@@ -171,10 +170,7 @@ Here are the available theme options:
171
170
Here are the custom style options for the notification inbox:
172
171
173
172
``` js
174
- type StyleProps = {
175
- notificationIcon?: {
176
- size?: number;
177
- };
173
+ type CustomStyleProps = {
178
174
window ?: {
179
175
width?: DimensionValue;
180
176
height?: DimensionValue;
@@ -183,6 +179,8 @@ Here are the custom style options for the notification inbox:
183
179
height?: number;
184
180
titleFontWeight?: TextStyle[' fontWeight' ];
185
181
titleSize?: number;
182
+ borderWidth?: string;
183
+ titlePadding?: number;
186
184
}
187
185
windowContainer?: {
188
186
padding?: number;
@@ -193,15 +191,12 @@ Here are the custom style options for the notification inbox:
193
191
avatarSize?: number;
194
192
titleFontWeight?: TextStyle[' fontWeight' ];
195
193
titleSize?: number;
194
+ subtitleFontWeight?: TextStyle[' fontWeight' ];
195
+ subtitleSize?: number
196
+ descriptionFontWeight?: TextStyle[' fontWeight' ];
196
197
descriptionSize?: number;
197
198
dateSize?: number;
198
199
};
199
- badgeStyle?: {
200
- size?: number;
201
- textSize?: number;
202
- top?: number;
203
- right?: number;
204
- };
205
200
deleteIcon?: {
206
201
size?: number
207
202
};
@@ -217,14 +212,16 @@ Here are the custom style options for the notification inbox:
217
212
``` js
218
213
type CardProps = {
219
214
hideAvatar?: boolean;
215
+ onAvatarClick?: (notification : NotificationDataType ) => void ;
220
216
disableAutoMarkAsRead?: boolean;
217
+ deleteIcon?: JSX .Element ;
221
218
hideDelete?: boolean;
222
219
};
223
220
```
224
221
225
- #### InboxHeaderProps
222
+ #### HeaderProps
226
223
``` js
227
- type InboxHeaderProps = {
224
+ type HeaderProps = {
228
225
title?: string;
229
226
hideHeader?: boolean;
230
227
hideClearAll?: boolean;
@@ -243,14 +240,14 @@ Here are the custom style options for the notification inbox:
243
240
import { useSiren } from ' @sirenapp/react-native-inbox' ;
244
241
245
242
function MyComponent () {
246
- const { markAsRead , deleteNotification } = useSiren ();
243
+ const { markAsReadById , deleteById } = useSiren ();
247
244
248
245
function handleMarkAsRead (id ) {
249
- markAsRead (id);
246
+ markAsReadById (id);
250
247
}
251
248
252
249
function handleDeleteNotification (id ) {
253
- deleteNotification (id);
250
+ deleteById (id);
254
251
}
255
252
256
253
return (
@@ -262,23 +259,11 @@ function MyComponent() {
262
259
263
260
Functions | Parameters | Type | Description |
264
261
----------|------------|-------|------------|
265
- markNotificationsAsReadByDate | startDate | ISO date string | Sets the read status of notifications to true until the given date |
266
- markAsRead | id | string | Set read status of a notification to true |
267
- deleteNotification | id | string | Delete a notification by id |
268
- deleteNotificationsByDate | startDate | ISO date string | Delete all notifications until given date |
269
- markNotificationsAsViewed | startDate | ISO date string |Sets the viewed status of notifications to true until the given date |
270
-
271
- ## 4. Error codes
272
- Given below are all possible error codes thrown by sdk:
273
-
274
- Error code | Description |
275
- --- | --- |
276
- INVALID_TOKEN | The token passed in the provider is invalid |
277
- INVALID_RECIPIENT_ID | The recipient id passed in the provider is invalid |
278
- TOKEN_VERIFICATION_FAILED | Verification of the given tokens has failed |
279
- GENERIC_API_ERROR | Occurrence of an unexpected api error |
280
- OUTSIDE_SIREN_CONTEXT | Attempting to invoke the functions outside the siren inbox context |
281
- MISSING_PARAMETER | The required parameter is missing |
262
+ markAsReadByDate | startDate | ISO date string | Sets the read status of notifications to true until the given date |
263
+ markAsReadById | id | string | Set read status of a notification to true |
264
+ deleteById | id | string | Delete a notification by id |
265
+ deleteByDate | startDate | ISO date string | Delete all notifications until given date |
266
+ markAllAsViewed | startDate | ISO date string |Sets the viewed status of notifications to true until the given date |
282
267
283
268
## Example
284
269
Here's a basic example to help you get started
@@ -312,7 +297,6 @@ function MyContainer(): React.JSX.Element {
312
297
darkMode= {false }
313
298
/ >
314
299
< SirenInbox
315
- title= " Notifications"
316
300
hideHeader= {false }
317
301
darkMode= {false }
318
302
cardProps= {{hideAvatar: false , disableAutoMarkAsRead: false }}
0 commit comments