From aa3c559e7b2348f059a4fc9eeffd095948fdffc5 Mon Sep 17 00:00:00 2001 From: Krystof Celba Date: Mon, 5 Feb 2018 23:10:24 +0100 Subject: [PATCH] Add simple example to readme how to send notification with category --- README.md | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 537bfe3..4d165d4 100644 --- a/README.md +++ b/README.md @@ -376,7 +376,7 @@ class App extends Component { body: "My Notification Message", // as FCM payload (required) sound: "default", // as FCM payload priority: "high", // as FCM payload - click_action: "ACTION", // as FCM payload + click_action: "com.myapp.MyCategory", // as FCM payload - this is used as category identifier on iOS. badge: 10, // as FCM payload IOS only, set 0 to clear badges number: 10, // Android only ticker: "My Notification Ticker", // Android only @@ -569,6 +569,26 @@ FCM.send('984XXXXXXXXX', { The `Data Object` is message data comprising as many key-value pairs of the message's payload as are needed (ensure that the value of each pair in the data object is a `string`). Your `Sender ID` is a unique numerical value generated when you created your Firebase project, it is available in the `Cloud Messaging` tab of the Firebase console `Settings` pane. The sender ID is used to identify each app server that can send messages to the client app. +### Sending remote notifications with category on iOS +If you want to send notification which will have actions as you defined in app it's important to correctly set it's `category` (`click_action`) property. It's also good to set `"content-available" : 1` so app will gets enough time to handle actions in background. + +So the fcm payload should look like this: +```javascript +{ + "to": "some_device_token", + "content_available": true, + "notification": { + "title": "Alarm", + "subtitle": "First Alarm", + "body": "First Alarm", + "click_action": "com.myapp.MyCategory" // The id of notification category which you defined with FCM.setNotificationCategories + }, + "data": { + "extra": "juice" + } + } + ``` + ## Q & A #### Why do you build another local notification -- 2.26.2