How to send actionable notifications to iOS with FireBase?

Thanks Malik for the answer. FCM seems to translate the android specific "click_action" property to the iOS specific "category" property.

We send firebase push notifications via their REST API, which can be easily used for testing with postman.

Here is the REST version:

POST https://fcm.googleapis.com/fcm/send

Headers:

  • Authorization: key=YOUR_FIREBASE_SERVER_KEY
  • Content-Type: application/json

Body:

{ "notification": {
    "text": "YOUR_PUSH_TEXT",
    "click_action":"YOUR_IOS_ACTIONABLE_NOTIFICATION_CATEGORY"
  },
  "to" : "YOUR_PUSH_TOKEN",
  "data": {
    "YOUR_CUSTOM_DATA": "DATA"
  }
}

Currently categories not supported in FCM console but still if you want to test you can use curl post call and test. You can add category to your payload from your server and use FCM api to push notification to iOS.

curl --header "Authorization: key=<YOUR_SERVER_KEY>" --header Content-  Type:"application/json" https://fcm.googleapis.com/fcm/send  -d "{\"to\":\"Device Token\",\"priority\":\"high\",\"notification\": {\"title\": \"Shift Alert\",\"text\": \"Would you like to accept  shift today 11:30 to 13:30  \",\"click_action\":\"INVITE_CATEGORY\"}}"

Authorization: key=YOUR_SERVER_KEY Make sure this is the server key, whose value is available in your Firebase project console under Project Settings > Cloud Messaging. Android, iOS, and browser keys are rejected by FCM.

INVITE_CATEGORY = Your category you using in your code

below is response dictionary you will get on action tap:

{
aps =     {
    alert =         {
        body = "Would you like to accept shift today 11:30 to 13:30  ";
        title = "Shift Alert";
    };
    category = "INVITE_CATEGORY";
};
"gcm.message_id" = "0:12233487r927r923r7329";
}