Is it possible to send bold text in JSON push notification body using Firebase Cloud Messaging?
Asked Answered
B

2

5

I am using Firebase Cloud Messaging to send push notification to IOS and Android devices. I would like to send some text in message body, which has a part of it bold. That's how my JSON looks like now for android push notifications:

{
  "message":{
    "token":"bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
    "notification":{
      "body":"Some plain text THIS TEXT SHOULD BE BOLD some plain text"
    }
  }
}

Now I would like to see the message in my push notification like this: "Some plain text THIS TEXT SHOULD BE BOLD some plain text"

Is it possible to do so?

Brannan answered 21/2, 2018 at 9:42 Comment(0)
C
2

You can send as Markdown and make your Android client parse it, so your message would be something like

{
  "message":{
    "token":"bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
    "notification":{
      "body":"Some plain text **THIS TEXT SHOULD BE BOLD** some plain text"
    }
  }
}
Carilyn answered 21/2, 2018 at 16:39 Comment(2)
It's not supported on iOS.Zincography
Didn't worked in Android as well.Barometrograph
M
5

It's not possible to change the font characteristics for notification type messages with FCM. If you need to do some special work to create a notification, you should instead send a message with a data payload, and deal with its contents yourself.

Macedo answered 21/2, 2018 at 16:38 Comment(0)
C
2

You can send as Markdown and make your Android client parse it, so your message would be something like

{
  "message":{
    "token":"bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
    "notification":{
      "body":"Some plain text **THIS TEXT SHOULD BE BOLD** some plain text"
    }
  }
}
Carilyn answered 21/2, 2018 at 16:39 Comment(2)
It's not supported on iOS.Zincography
Didn't worked in Android as well.Barometrograph

© 2022 - 2024 — McMap. All rights reserved.