I am making a messaging app, and when I send emoji from the Android side, it shows great on the iOS side, but the iOS side cannot (seem to) display emojis from the iOS native keyboard!
The label on which I display emoji uses attribute text, and the text is from HTML. The following code is used to create an NSAttributedString
var msg = getTextForDisplay()//Essentially gets the plain text msg = "<span style=\"font-family: Helvetica; font-size:14pt;\">" + msg + "</span>" if let data = msg.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false){ let attributed = try? NSAttributedString(data: data, options: [ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType ], documentAttributes: nil) return attributed }
Even a stranger, when I send emoji from iOS, although it does not appear on the shortcut as described above, it shows perfectly on the Android side. On the iOS side, the shortcut displays what seems funny (unicode chasracters, maybe?)
eg: 
I am absolutely sure that the error is related to the display of emoji, because when you print to the console, I see real emoji, and also when saving to the device storage and later read on Mac, it is real emoji. But when emoji loads in attribute tag, it shows jibberish
Any help is appreciated. I understand that the problem is with the encoding. I'm just not sure what the problem is and how to fix it.
source share