Using Whatsapp 'Click To Chat' I'm able to send a message to a number, as expected. But, I want to send some emojis in the prefilled message. It works well when I use a browser, but it doesn't work when I use a WebView inside an app (specifically a React Native app with a webview running the same site).
The problem:
For both, desktop browser or webView I use the same function and same encoding (encodeURI()
), but
when the WebView calls the Whatsapp URL ("wa.me/...") the chat on Whatsapp shows all emojis as: �
- Is it even possible to use emojis on Whatsapp Click to Chat? (I bet it is, since desktop browser works).
- What can be happening on mobile/app?
- Should I use some kind of character encoding, as unicode, UTF-8 (I already tested some, but no success)?
Here's the function that I'm using:
SendWhatsapp = function(message, number) {
number = LibGeral.NormalizeMobileNumber(number);
if (empty(message)) {
message = "";
}
var urlApiWhats = "/" + number + "?text=" + message;
urlApiWhats = encodeURI(urlApiWhats);
var a = document.createElement("a");
a.setAttribute("data-action", "share/whatsapp/share")
a.href = urlApiWhats;
window.document.body.appendChild(a)
a.click();
window.document.body.removeChild(a);
return true;
}
SendWhatsapp("I'm a message with emoji