Commit 8cea39ef authored by d4vidi's avatar d4vidi

Update readme with info regarding local notifications on Android

parent 7b9d6ee2
......@@ -273,9 +273,9 @@ PendingNotifications.getInitialNotification()
## Triggering Local Notifications
> Currently, an iOS-only feture
### iOS
You can schedule a local notification for future presentation.
You can manually trigger local notifications in your JS code, to be posted immediately or in the future.
Triggering local notifications is fully compatible with React Native `PushNotificationsIOS` library.
Example:
......@@ -293,7 +293,7 @@ let localNotification = NotificationsIOS.localNotification({
Notification object contains:
- `fireDate`- The date and time when the system should deliver the notification (optinal. default is immidiate dispatch).
- **`fireDate`**- The date and time when the system should deliver the notification (optinal - default is immidiate dispatch).
- `alertBody`- The message displayed in the notification alert.
- `alertTitle`- The title of the notification, displayed in the notifications center.
- `alertAction`- The "action" displayed beneath an actionable notification.
......@@ -301,10 +301,24 @@ Notification object contains:
- `category`- The category of this notification, required for [interactive notifications](#interactive--actionable-notifications-ios-only) (optional).
- `userInfo`- An optional object containing additional notification data.
### Android
Much like on iOS, notifications can be triggered locally. The API to do so is a simplified version of the iOS equivalent that works more natually with the Android perception of push (remote) notifications:
```javascript
NotificationsAndroid.localNotification({
title: "Local notification",
body: "This notification was generated by the app!",
extra: "data"
});
```
Upon notification opening (tapping by the device user), all data fields will be delivered as-is).
### Cancel Local Notification
```NotificationsIOS.localNotification``` method returns `notificationId`, which is used in order to cancel created local notification. You can cancel local notification by calling `NotificationsIOS.cancelLocalNotification(notificationId)` method.
The `NotificationsIOS.localNotification()` and `NotificationsAndroid.localNotification()` methods return unique `notificationId` values, which can be used in order to cancel specific local notifications. You can cancel local notification by calling `NotificationsIOS.cancelLocalNotification(notificationId)` or `NotificationsAndroid.cancelLocalNotification(notificationId)`.
Example:
Example (iOS):
```javascript
let someLocalNotification = NotificationsIOS.localNotification({
......@@ -319,7 +333,7 @@ let someLocalNotification = NotificationsIOS.localNotification({
NotificationsIOS.cancelLocalNotification(someLocalNotification);
```
### Cancel All Local Notifications
### Cancel All Local Notifications (iOS-only!)
```javascript
NotificationsIOS.cancelAllLocalNotifications();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment