javascript 如何在 iOS 移动网站上添加“在 whatsapp 上分享”按钮
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28541693/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to add "Share on whatsapp" button on mobile website for iOS
提问by Pavan Vamsi
Adding whatsapp share button on website, for iOS8. I am using the following:
在网站上添加 whatsapp 分享按钮,适用于 iOS8。我正在使用以下内容:
<spanid="whatsapp_share_android">
<a href="whatsapp://send?text={{my_meta.og_title.value}} - http://{{ request.get_host }}{{entity.url}}%3Futm_source=whatsapp%26utm_medium=referral" data-action="share/whatsapp/share" onmousedown="_paq.push(['trackEvent','Share on Whatsapp','Mobile','{{request.get_full_path}}']); ga('send', 'event','Share on Whatsapp','Mobile','{{request.get_full_path}}');ga('mobileTracker.send', 'event','Share on Whatsapp','Mobile','{{request.get_full_path}}');"><img src="{{ STATIC_URL }}images/whatsapp_icon.png" /></a>
</span>
It works on android but not on iOS
它适用于Android,但不适用于iOS
回答by Patrick Rudolph
According to the WhatsApp FAQ for app integration, your URL scheme should work:
根据应用程序集成的 WhatsApp 常见问题解答,您的 URL 方案应该有效:
- I'm an iPhone developer, how can I integrate WhatsApp into my app?
- I'm an Android developer, how can I integrate WhatsApp with my app?
I assume that everything within brackets in your sample code will be replaced by your app? Also there needs to be a space between the span
tag and its id
attribute.
我假设您的示例代码中括号内的所有内容都将被您的应用程序替换?span
标签和它的id
属性之间也需要有一个空格。
How about if you try it with this simple example on both platforms:
如果你在两个平台上用这个简单的例子尝试一下怎么样:
<a href="whatsapp://send?text=Hello%20World!">Hello, world!</a>