You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| notificationBodyComponent |**See below about NotificationBody**| React Node or Function | Recommended |`./DefaultNotificationBody`|
39
69
40
70
### NotificationBody
71
+
41
72
The notification body is what is rendered inside the main Notification component and gives you the ability to customise how the notification looks. You can use the default notification body component in `./DefaultNotificationBody.js` as inspiration and guidance.
42
73
43
74
Your `notificationBodyComponent` component is given four props:
44
75
45
76
| Prop Name | Prop Description | Data Type | Default |
| title | The title passed to `NotificationRef.show`| String |`''`|
48
79
| message | The message passed to `NotificationRef.show`| String |`''`|
49
80
| onPress | The callback passed to `NotificationRef.show`| Function |`null`|
50
81
| icon | Icon for notification passed to `NotificationRef.show`| ImageSourcePropType |`null`|
51
82
| vibrate | Vibrate on show notification passed to `NotificationRef.show`| Boolean |`true`|
52
83
53
84
## Usage
54
-
Adding `react-native-in-app-notification` is simple; just import the component and add it to the bottom of your component tree. Then create a ref to the component using `ref={(ref) => { this.notification = ref; }}` as a prop.
55
85
56
-
When you want to show the notification, just call `.show` on the ref you made earlier. `.show` can take three arguments: `title`, `message` and `onPress` all of which are optional - but you should probably include at least one of `title` or `message`! `onPress` doesn't need to be used for passive notifications and you can use `onClose` in your `NotificationBody` component to allow your users to close the notification.
86
+
Adding `react-native-in-app-notification` is simple;
87
+
Just wrap you main `App` component with the `InAppNotificationProvider` component exported from this module.
When you want to show the notification, just wrap the component which needs to display a notification with the `withInAppNotification` HOC and call the `.showNotification` methods from its props.
106
+
107
+
`.showNotification` can take three arguments (all of which are optional):
108
+
109
+
-`title`
110
+
-`message`
111
+
-`onPress`
112
+
113
+
**N.B:** you should probably include at least one of `title` or `message`!
114
+
115
+
`onPress` doesn't need to be used for passive notifications and you can use `onClose` in your `NotificationBody` component to allow your users to close the notification.
0 commit comments