@@ -9,12 +9,12 @@ The `@sirenapp/react-native-inbox` sdk is a comprehensive and customizable React
9
9
You can install the react sdk from npm
10
10
11
11
``` bash
12
- npm @sirenapp/react-native-inbox
12
+ npm install @sirenapp/react-native-inbox
13
13
```
14
14
or from yarn
15
15
16
16
``` bash
17
- yarn @sirenapp/react-native-inbox
17
+ yarn add @sirenapp/react-native-inbox
18
18
```
19
19
20
20
## 2. Configuration
@@ -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,17 +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 | {} |
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 | {} |
116
113
darkMode | Toggle to enable dark mode| boolean | false |
117
114
itemsPerFetch | 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 } |
123
120
customFooter | Custom footer component | JSX Element | null |
124
121
customLoader | Custom component to display the initial loading state| JSX Element | null |
125
122
customErrorWindow | Custom error window | JSX Element | null |
@@ -154,7 +151,6 @@ Here are the available theme options:
154
151
titleColor?: string;
155
152
headerActionColor?: string;
156
153
borderColor?: string;
157
- borderWidth?: string;
158
154
};
159
155
windowContainer?: {
160
156
background?: string;
@@ -163,8 +159,8 @@ Here are the available theme options:
163
159
borderColor?: string;
164
160
background?: string;
165
161
titleColor?: string;
162
+ subTitleColor?: string;
166
163
descriptionColor?: string;
167
- dateColor?: string;
168
164
};
169
165
}
170
166
```
@@ -174,10 +170,7 @@ Here are the available theme options:
174
170
Here are the custom style options for the notification inbox:
175
171
176
172
``` js
177
- export type StyleProps = {
178
- notificationIcon ?: {
179
- size ?: number ;
180
- };
173
+ type CustomStyleProps = {
181
174
window ?: {
182
175
width?: DimensionValue;
183
176
height?: DimensionValue;
@@ -186,6 +179,8 @@ Here are the custom style options for the notification inbox:
186
179
height?: number;
187
180
titleFontWeight?: TextStyle[' fontWeight' ];
188
181
titleSize?: number;
182
+ borderWidth?: string;
183
+ titlePadding?: number;
189
184
}
190
185
windowContainer?: {
191
186
padding?: number;
@@ -196,26 +191,48 @@ Here are the custom style options for the notification inbox:
196
191
avatarSize?: number;
197
192
titleFontWeight?: TextStyle[' fontWeight' ];
198
193
titleSize?: number;
194
+ subtitleFontWeight?: TextStyle[' fontWeight' ];
195
+ subtitleSize?: number
196
+ descriptionFontWeight?: TextStyle[' fontWeight' ];
199
197
descriptionSize?: number;
200
198
dateSize?: number;
201
199
};
202
- badgeStyle?: {
203
- size?: number;
204
- textSize?: number;
205
- top?: number;
206
- right?: number;
207
- };
208
200
deleteIcon?: {
209
201
size?: number
210
202
};
211
- dateIcon ?: {
203
+ timerIcon ?: {
212
204
size?: number
213
205
};
214
206
clearAllIcon?: {
215
207
size?: number
216
208
};
217
209
};
218
210
```
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
+ ```
219
236
220
237
## 3. Hooks
221
238
@@ -225,14 +242,10 @@ Here are the custom style options for the notification inbox:
225
242
import { useSiren } from ' @sirenapp/react-native-inbox' ;
226
243
227
244
function MyComponent () {
228
- const { markAsRead , deleteNotification } = useSiren ();
245
+ const { markAsReadById , deleteById } = useSiren ();
229
246
230
247
function handleMarkAsRead (id ) {
231
- markAsRead (id);
232
- }
233
-
234
- function handleDeleteNotification (id ) {
235
- deleteNotification (id);
248
+ markAsReadById (id);
236
249
}
237
250
238
251
return (
@@ -244,23 +257,11 @@ function MyComponent() {
244
257
245
258
Functions | Parameters | Type | Description |
246
259
----------|------------|-------|------------|
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 |
264
265
265
266
## Example
266
267
Here's a basic example to help you get started
@@ -294,10 +295,9 @@ function MyContainer(): React.JSX.Element {
294
295
darkMode= {false }
295
296
/ >
296
297
< SirenInbox
297
- title= " Notifications"
298
298
hideHeader= {false }
299
299
darkMode= {false }
300
- cardProps= {{hideAvatar: false }}
300
+ cardProps= {{hideAvatar: false , disableAutoMarkAsRead : false }}
301
301
/ >
302
302
< / View>
303
303
);
0 commit comments