0

In Android, it is possible to have rich text effect in the notification. In the following Android's screenshot, we have text with the following additional attributes

  1. Strikethrough
  2. Grey text color

enter image description here


I was wondering, in iOS, is it possible to have rich text effect on notification text?

At initial glance on API, it seems that we are NOT able to do so

let content = UNMutableNotificationContent()
// content.title is String type, not NSAttributedString
content.title = ...
// content.body is String type, not NSAttributedString
content.body = ...

This is the best I can have so far.

enter image description here

I know that it is possible to have image shown in the notification, with the following additional work described in https://www.avanderlee.com/swift/rich-notifications/

However, I do not find a way, to have rich text effect (strikethrough, text color) in notification text? Is it not possible to do so in iOS, or I have been missing something?

Thank you.

Cheok Yan Cheng
  • 47,586
  • 132
  • 466
  • 875

1 Answers1

0

You can get the complete text as HTML text from server side. And in content extension notification target, on label you can convert HTML to text.

HTML content could contain any effects like Strikethrough, bold, new line, text color etc.

just use label and convert HTML to normal text by this link.

Happy Coding :)

Himani Sharma
  • 1,550
  • 2
  • 10
  • 12