From 8cea39ef47ca1e4262ae5e895ce76d5f33070c10 Mon Sep 17 00:00:00 2001 From: d4vidi Date: Tue, 29 Nov 2016 16:55:42 +0200 Subject: [PATCH] Update readme with info regarding local notifications on Android --- README.md | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index b734359..0c81918 100644 --- a/README.md +++ b/README.md @@ -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(); -- 2.26.2