1- <div >
2- <img width="50px" style="float:left;padding-right:12px;" src="https://app.dev.sirenapp.io/assets/Siren-b2f89b52.svg" >
3- <H1>Siren React Native Inbox</H1>
4- </div >
5-
6- ## Table of Contents
7- <!-- MarkdownTOC -->
8- - [ Overview] ( #overview )
9- - [ Quick Start Guide] ( #quick-start-guide )
10- - [ Install SDK] ( #1-install-sdk )
11- - [ Siren Provider] ( #2-siren-provider )
12- - [ Siren Notification Icon] ( #3-siren-notification-icon )
13- - [ Siren Inbox] ( #4-siren-inbox )
14- - [ useSiren] ( #5-usesiren )
15- - [ Error Codes] ( #6-error-codes )
16- - [ Complete Code Example] ( #complete-code-example )
17- - [ I want to know more!] ( #i-want-to-know-more )
18-
19- <!-- /MarkdownTOC -->
20-
21-
22- <a name =" introduction " ></a >
1+ # Siren React Native Inbox
2+
233## Overview
244
25- The @siren/react-native-inbox sdk is a comprehensive and customizable React Native UI kit for displaying and managing notifications. This documentation provides comprehensive information on how to install, configure, and use the sdk effectively.
5+ The ` @siren/react-native-inbox ` sdk is a comprehensive and customizable React Native UI kit for displaying and managing notifications. This documentation provides comprehensive information on how to install, configure, and use the sdk effectively.
266
27- ## Quick Start Guide
7+ ## 1. Installation
288
29- ### 1. Install SDK
30- To install the @siren/react-native-inbox sdk, you can use npm or yarn.
9+ You can install the react sdk from npm
3110
32- #### Prerequisites
33- - React Native v0.6+
34- #### Steps
35- 1 . Under your app's root directory, install @siren/react-native-inbox .
36- ```
37- npm install @siren/react-native-inbox
11+ ``` bash
12+ npm @siren/react-native-inbox
3813```
39- 2 . Under your application's ios folder, run
14+ or from yarn
15+
16+ ``` bash
17+ yarn @siren/react-native-inbox
4018```
41- pod install
42- ```
4319
44- ### 2. Siren Provider
45- The SirenProvider initializes the Siren sdk with the specified configuration, which contains important parameters like the user token and recipient ID. Wrap the SirenProvider around your App's root.
20+ ## 2. Configuration
21+ ### 2.1 Initialization
22+ Initialize the sdk with user token and recipient id. Wrap the provider around your App's root.
4623
4724``` js
4825import { SirenProvider } from ' @siren/react-native-inbox' ;
@@ -55,50 +32,35 @@ const config = {
5532< SirenProvider config= {config}>
5633 {/* Your app components */ }
5734< / SirenProvider>
58-
59-
6035```
61- The config is a property containing userToken and recipientId for authenticate and initialize sdk.
6236
63- ``` js
64- type config = {
65- userToken: string,
66- recipientId: string,
67- };
68- ```
69-
70- ### 3. Siren Notification Icon
71- This component includes a customizable notification icon and a badge for indicating the number of un-viewed notifications in the user interface.
37+ ### 2.2 Configure notification icon
38+ Once the provider is configured, next step is to configure the notification icon
7239
40+ This component consists of a notification icon along with a badge to display the number of unviewed notifications
7341``` js
7442import { SirenInboxIcon } from ' @siren/react-native-inbox' ;
7543
76- < SirenInboxIcon
77- theme= {customTheme}
78- customStyles= {customStyles}
79- notificationIcon= {< CustomIcon / > }
80- darkMode= {true }
81- onError= {(error ) => console .error (error)}
82- / >
44+ < SirenInboxIcon / >
8345
8446```
8547
86- #### Siren Notification Icon Props
87- Given below are all props of Icon component.
48+ #### Props for notification icon
49+ Below are optional props available for the icon component:
8850
8951Prop | Description | Type | Default value |
9052--- | --- | --- | --- |
91- theme | Theme object for custom color theme | Theme | {} |
92- customStyles | Style object for custom styling | StyleProps | {} |
93- notificationIcon | Option to use custom notification Icon | JSX Element | null |
94- darkMode | Flag to enable dark mode | boolean | false |
53+ theme | Object for custom themes | Theme | {} |
54+ customStyles | Object for custom styling | StyleProps | {} |
55+ notificationIcon | Option to use custom notification icon | JSX Element | null |
56+ darkMode | Toggle to enable dark mode | boolean | false |
9557onError | Callback for handling errors | (error: SirenErrorType)=> void | null |
96- onPress | Function for handling press of icon | ()=> void | null |
97- disabled | Flag to disable click handler of icon | boolean | false |
98- hideBadge | Flag to hide unread notification count badge | boolean | false |
58+ onPress | Custom click handler for notification icon | ()=> void | null |
59+ disabled | Toggle to disable click on icon | boolean | false |
60+ hideBadge | Toggle to hide unviewed count badge | boolean | false |
9961
100- #### Theming options
101- Customize the unread badge of the notification icon, and choose between dark and light theming options.
62+ #### Theme customization
63+ Here are the available theme options:
10264
10365``` js
10466 type Theme = {
@@ -114,9 +76,8 @@ Customize the unread badge of the notification icon, and choose between dark and
11476 }
11577```
11678
117- #### Styling options
118- Customize the notification icon style properties includes size of icon, badge, etc.
119-
79+ #### Style customization
80+ Here are the custom style options for the notification icon:
12081``` js
12182
12283 type StyleProps = {
@@ -132,58 +93,42 @@ Customize the notification icon style properties includes size of icon, badge, e
13293 }
13394```
13495
135- ### 4. Siren Inbox
96+ ### 2.3. Configure notification inbox
13697
137- SirenNotificationInbox is a paginated list view for displaying notifications.
98+ Inbox is a paginated list view for displaying notifications.
13899
139100``` js
140101import { SirenInbox } from ' @siren/react-native-inbox' ;
141102
142- < SirenInbox
143- theme= {customTheme}
144- title= " Notifications"
145- hideHeader= {false }
146- darkMode= {true }
147- onError= {(error ) => console .log (error)}
148- / >
103+ < SirenInbox / >
149104
150105```
151- #### Siren Notification Inbox Props
152- Given below are all props of inbox component.
106+ #### Props for the notification inbox
107+ Below are optional props available for the inbox component:
153108
154109Prop | Description | Type | Default value |
155110--- | --- | --- | --- |
156- theme | Theme object for custom color theme | Theme | {} |
157- customStyles | Style object for custom styling | StyleProps | {} |
111+ theme | Object for custom themes | Theme | {} |
112+ customStyles | Object for custom styling | StyleProps | {} |
158113title | Title of the notification inbox | string | "Notifications" |
159- hideHeader | Flag to hide or show the header | boolean | false |
160- hideClearAll | Flag to hide or show the clear all button in header | boolean | false |
161- darkMode | Flag to enable dark mode | boolean | false |
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 |
116+ darkMode | Toggle to enable dark mode| boolean | false |
162117itemsPerFetch | Number of notifications fetch per api request (have a max cap of 50) | number | 20 |
163- cardProps | Props for customizing the notification cards | CardProps | null |
164- customNotificationCard | Custom function for rendering notification cards | (notification)=> JSX Element | null |
165- onNotificationCardClick | Props for customizing the notification cards | (notification)=> void | ()=>null |
166- listEmptyComponent | Custom component to display when the notification list is empty | JSX Element | null |
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 |
167122customHeader | Custom header component | JSX Element | null |
168123customFooter | Custom footer component | JSX Element | null |
169- customLoader | Custom loader component | JSX Element | null |
170- customErrorWindow | Custom error component | JSX Element | null |
124+ customLoader | Custom component to display the initial loading state | JSX Element | null |
125+ customErrorWindow | Custom error window | JSX Element | null |
171126onError | Callback for handling errors | (error: SirenErrorType)=> void | null |
172127
173- #### Card props
174128
175- Style object for customize notification card.
129+ #### Theme customization
176130
177- ``` js
178- type CardProps = {
179- hideAvatar?: boolean;
180- showMedia?: boolean;
181- };
182- ```
183-
184- #### Theming options
185-
186- Customizable UI option for notification inbox, with dark and light theme options.
131+ Here are the available theme options:
187132
188133``` js
189134 type Theme = {
@@ -224,9 +169,9 @@ Customizable UI option for notification inbox, with dark and light theme options
224169 }
225170```
226171
227- #### Styling options
172+ #### Style options
228173
229- Customizable Styling option for notification inbox.
174+ Here are the custom style options for the notification inbox:
230175
231176``` js
232177 export type StyleProps = {
@@ -273,8 +218,9 @@ Customizable Styling option for notification inbox.
273218 };
274219```
275220
276- ### 5. useSiren
277- This is a hook that provides utility functions for modifying notifications.
221+ ## 3. Hooks
222+
223+ ` useSiren ` is a hook that provides utility functions for modifying notifications.
278224
279225``` js
280226import { useSiren } from ' @siren/react-native-inbox' ;
@@ -297,29 +243,28 @@ function MyComponent() {
297243```
298244#### useSiren functions
299245
300- Function name | Parameters type | Description |
301- --- | --- | --- |
302- markAllNotificationsAsReadByDate | startDate: string | Set all notification read status to true until given date |
303- markAsRead | id: string | Set read status of a specific notification to true |
304- deleteNotification | id: string | Delete a specific notification by id |
305- deleteNotificationsByDate | startDate: string | Delete all notifications until given date |
306- markNotificationsAsViewed | startDate: string | Set all notification viewed status to true until given date |
307-
308- ### 6. Error codes
309- Given below are all possible error codes thrown by sdk.
310-
311- Error code | Message | Description |
312- --- | --- | --- |
313- INVALID_TOKEN | Invalid token | Token passed in provider is invalid |
314- INVALID_RECIPIENT_ID | Invalid recipient id | Recipient id in provider is invalid |
315- TOKEN_VERIFICATION_FAILED | This operation requires a valid token | Failed to verify token and initialize sdk |
316- INVALID_ERROR_FUNCTION | Invalid error function | Error function is invalid |
317- GENERIC_API_ERROR | Api error | Failed to call a internal api |
318- OUTSIDE_SIREN_CONTEXT | Siren Object Not found | Was failed to initialize sdk, Siren object not created |
319- MISSING_PARAMETER | Missing Parameter | A parameter is missing in function call |
320-
321- ### Complete Code Example
322- Here's a runnable code example that covers everything in this quick start guide.
246+ Functions | Parameters | Type | Description |
247+ ----------|------------|-------|------------|
248+ markAllNotificationsAsReadByDate | startDate | ISO date string | Sets the read status of notifications to true until the given date |
249+ markAsRead | id | string | Set read status of a notification to true |
250+ deleteNotification | id | string | Delete a notification by id |
251+ deleteNotificationsByDate | startDate | ISO date string | Delete all notifications until given date |
252+ markNotificationsAsViewed | startDate | ISO date string |Sets the viewed status of notifications to true until the given date |
253+
254+ ## 4. Error codes
255+ Given below are all possible error codes thrown by sdk:
256+
257+ Error code | Description |
258+ --- | --- |
259+ INVALID_TOKEN | The token passed in the provider is invalid |
260+ INVALID_RECIPIENT_ID | The recipient id passed in the provider is invalid |
261+ TOKEN_VERIFICATION_FAILED | Verification of the given tokens has failed |
262+ GENERIC_API_ERROR | Occurrence of an unexpected api error |
263+ OUTSIDE_SIREN_CONTEXT | Attempting to invoke the functions outside the siren inbox context |
264+ MISSING_PARAMETER | The required parameter is missing |
265+
266+ ## Example
267+ Here's a basic example to help you get started
323268``` js
324269
325270import React from ' react' ;
@@ -345,26 +290,20 @@ export default App;
345290function MyContainer (): React.JSX.Element {
346291
347292 return (
348- < SafeAreaView style = {{flex : 1 }} >
293+ < View >
349294 < SirenInboxIcon
350295 darkMode= {false }
351296 / >
352297 < SirenInbox
353298 title= " Notifications"
354299 hideHeader= {false }
355300 darkMode= {false }
356- cardProps= {{hideAvatar: false , showMedia : true }}
301+ cardProps= {{hideAvatar: false }}
357302 / >
358- < / SafeAreaView >
303+ < / View >
359304 );
360305}
361306
362307export default MyContainer ;
363308
364- ```
365-
366- ### I want to know more!
367-
368- No worries, here are some links that you will find useful:
369- * ** [ Advanced React Native Guide] ( https://reactnative.dev/docs/environment-setup ) **
370-
309+ ```
0 commit comments