最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Whatsapp Click to Chat with emojis - Stack Overflow

programmeradmin5浏览0评论

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 
发布评论

评论列表(0)

  1. 暂无评论