Search code examples
javasmsemojivonage

Using emojis via text message in Java


I've been trying to using emojis in the code for about an hour with no success. The emoji displays successfully on the console but as soon as I send myself a text message, everything breaks and this happens. Emoji fails to work

Here is my code right now, not sure what to do, any help would be appreciated:

SmsSubmissionResult[] response = 
client.getSmsClient().submitMessage(new TextMessage(
                "REMOVED",
                "REMOVED",
                "**\ud83d\ude36** Homework Task Due (18th December 
2017)\n**\ud83d\ude3c** For English: Revise for end of term 
test\n**\ud83d\ude47** This will take approximately 1 hour.\n\n"));

Solution

  • You appear to be sending the message using this constructor of TextMessage.

    TextMessage(String from, String to, String messageBody)
    

    Use the one with is unicode flag, set it to true:

     TextMessage(String from, String to, String messageBody, boolean unicode)