2

I'm using FCM to publish push notifications to my users, which is working great so far.

Currently I'm trying to implement a Notification Content Extension to deliver customized push notification and previews, which is working great with local notifications, following this post. As far I know, I have to set the category entry and my notification category identifier in the push notification, in order to tell iOS, which notification UI it is supposed to use.

The problem is, when I send the following message to FCM, with the category entry set, FCM erases the entry or changes it to gcm.notification.category, depending where I place the category entry (aps / data, etc.)

This way iOS never shows my custom UI / extension. Unfortunately I was not able to find any help in the FCM documentation.

Send (POST: https://fcm.googleapis.com/fcm/send):

{ 
    "notification": {
        "title": "Good Morning",
        "body": "Wake up Jack!",
        "badge" : 1,
        "sound" : "horn.aiff",
        "category" : "Cheers"     <-- Is going to be deleted / changed
    },

    "data" : {
        "time" : "2018-01-19 23:00:00",
        ...
    },

    "mutable_content" : true,

    "priority" : "high",
    "registration_ids" : [
      "abcdefg123456"
    ]
}

Received:

{
    aps =     {
        alert =         {
            body = "Wake up Jack!";
            title = "Good Morning";
        };
        badge = 1;
        "mutable-content" = 1;
    };

    "gcm.message_id" = "0:1516392279506894%dc84760ddc84760d";
    "gcm.notification.category" = "Cheers";    <-- not working 
}
user3191334
  • 1,148
  • 3
  • 15
  • 33
  • Hi. Could you also post the *actual payload* you send with FCM? The one that isn't translated to APNs payload yet. – AL. Jan 20 '18 at 09:17
  • Hi Al, thanks for your response and the hint, I copied the wrong JSON - it's up to date now :-) – user3191334 Jan 20 '18 at 10:36
  • 3
    Hmm. The `category` counterpart of the APNS payload for the FCM is `click_action` (as per the [docs](https://firebase.google.com/docs/cloud-messaging/http-server-ref)). Have you tried it out?\ – AL. Jan 20 '18 at 12:09
  • 1
    You are the best! Thank you so much! - Feel free to post an answer and I'm happy to accept it! Have a great day! – user3191334 Jan 20 '18 at 12:25
  • You're welcome. I'll add it in. – AL. Jan 20 '18 at 12:48

1 Answers1

6

The category APNS parameter FCM counterpart is click_action.

When adding in a custom parameter (using the data message payload), it is handled differently for iOS and is often included outside of the aps payload (like in the sample you provided).

AL.
  • 36,815
  • 10
  • 142
  • 281
  • Are we able to send schedule notifications like every day at a specific time using https://fcm.googleapis.com/fcm/send? (not from firebase console) – Kishan Bhatiya Oct 27 '21 at 09:19