Commit ce6fcf32 authored by Libin Lu's avatar Libin Lu Committed by GitHub

Update README.md

parent 669d2630
......@@ -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
......
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