From ce6fcf32710ce8c0bb3acff89de5092830774510 Mon Sep 17 00:00:00 2001 From: Libin Lu Date: Mon, 5 Dec 2016 13:36:44 -0500 Subject: [PATCH] Update README.md --- README.md | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7083337..5c52a22 100644 --- a/README.md +++ b/README.md @@ -270,6 +270,7 @@ class App extends Component { } otherMethods(){ + FCM.subscribeToTopic('/topics/foo-bar'); FCM.unsubscribeFromTopic('/topics/foo-bar'); FCM.getInitialNotification().then(notif=>console.log(notif)); @@ -305,8 +306,15 @@ class App extends Component { }) FCM.getScheduledLocalNotifications().then(notif=>console.log(notif)); - FCM.cancelLocalNotification("UNIQ_ID_STRING"); - FCM.cancelAllLocalNotifications(); + + //these clears notification from notification center/tray + FCM.removeAllDeliveredNotifications() + FCM.removeDeliveredNotification("UNIQ_ID_STRING") + + //these removes future local notifications + FCM.cancelAllLocalNotifications() + FCM.cancelLocalNotification("UNIQ_ID_STRING") + FCM.setBadgeNumber(); // iOS only and there's no way to set it in Android, yet. FCM.getBadgeNumber().then(number=>console.log(number)); // iOS only and there's no way to get it in Android, yet. FCM.send('984XXXXXXXXX', { @@ -317,6 +325,32 @@ class App extends Component { } ``` +### Build custom push notification for Andorid +Firebase android misses important feature of android notification like `group`, `priority` and etc. As a work around you can send data message (no `notification` payload at all) and this repo will build a local notification for you. If you pass `custom_notification` in the payload, the repo will treat the content as a local notification config and shows immediately. + +NOTE: By using this work around, you will have to send different types of payload for iOS and Android devices. + +Example of payload that is sent to FCM server: +``` +{ + "to":"FCM_TOKEN", + "data": { + "type":"MEASURE_CHANGE", + "custom_notification": { + "body": "test body", + "title": "test title", + "color":"#00ACD4", + "priority":"high", + "icon":"ic_notif", + "group": "GROUP", + "id": "id" + } + } +} +``` + +Check local notification guide below for configuration. + ### Behaviour when sending `notification` and `data` payload through GCM - When app is not running and user clicks notification, notification data will be passed into `FCM.getInitialNotification` event -- 2.26.2