2

The app is on both iOS and Android, for this notification to work on both platforms, I removed notification field from notification json payload. But now iOS does not handle this notification when in background.

This one works on iOS but it has notification field which I do not want.

{
  "registration_ids": [
        "...",
        "..."
    ],
  "priority": "high",
  "notification": {
    "body": "Notification Body.",
    "title": "Notification Title"
  },
  "data": {
    "userId": "11111",
    "badge": 10
  }
}

This one works in android but not working on iOS when in background:

{
  "registration_ids": [
        "...",
        "..."
    ],
  "mutable_content": true,
  "content_available": true,
  "data": {
    "click_action": "AndroidIntent"
    "message": "Notification Body",
    "myDataField": "11",
    "location": "3",
    "imageurl": "http://image.com/13fd.png"
  }
}

The bottom one does not even enter my Notification Service Extension. How do I make sure my Notification Service Extension is called without adding a notification field on my json?

yigitserin
  • 573
  • 2
  • 6
  • 24
  • This may help: https://stackoverflow.com/questions/40807397/firebase-fcm-silent-push-notifications-for-ios?rq=1 – Mike Taverne Nov 06 '18 at 15:21
  • 1
    Did the above one with "notification" key in the payload enters Notification Service Extension? I'm having same problem as well. My Notification Service doesn't get called that's why I cannot create a thumbnail on my notification via FCM. – Jongers Jan 25 '19 at 07:34
  • did you solve it bro.... can you share the solution please..... – Mostafa ALZOUBI May 10 '22 at 08:46
  • are you solve it bro I'm stuck in the same problem .... please share the solution – Mostafa ALZOUBI May 10 '22 at 10:16
  • Anyone lucky? There is a bounty on my question: https://stackoverflow.com/questions/75958704/handling-data-notification-only-in-both-ios-and-android-fails – J. Doe Apr 13 '23 at 19:45

2 Answers2

0

I have the same thoughts. I was thinking of receiving data from firebase and push local notification with customized title and body with notification service extention. This idea worked fine in foreground by implementing didReceiveRemoteNotification userInfo: in appDelegate to receive userInfo.

But it didn't work in background mode by enabling content_available. you send notification using APN Servers not Fcm Servers relating to firebase docs. I suggest to have a look in content_available and mutable_content

XPD
  • 1,121
  • 1
  • 13
  • 26
0

Remove content_available since this is the property to handle silent notifications.

Sophy Swicz
  • 1,307
  • 11
  • 21