Android 使用自定义文本/内容从 URL HREF 启动 WhatsApp
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21500570/
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
Start WhatsApp from URL HREF with custom text/content
提问by edan_develop
As you know using the whatsapp url scheme on iphone i can create the following link:
如您所知,在 iphone 上使用 whatsapp url 方案,我可以创建以下链接:
href="whatsapp://send?text=blahblah"
this is possible due to the url scheme support on ios.
由于 ios 上的 url 方案支持,这是可能的。
im try to create the similar effect for android devices. (but no threw android app, just a normal html page).
我尝试为 android 设备创建类似的效果。(但没有抛出 android 应用程序,只是一个普通的 html 页面)。
to my understanding it should be something like:
据我所知,它应该是这样的:
href="intent://send/#Intent;scheme=whatsapp;package=com.whatsapp;s.text=test;end;"
or:
或者:
href="intent://send/#Intent;scheme=whatsapp;package=com.whatsapp;text=test;
action=android.content.Intent.ACTION_SEND; end"
or:
或者:
href="intent://send/#Intent;scheme=whatsapp;package=com.whatsapp;text=test;
category=android.intent.category.BROWSABLE;end"
as you can see im really groping in the dark. all the answers i've found on stackoverflow are talking about how to generate the intent threw the android app.
正如你所看到的,我真的在黑暗中摸索。我在 stackoverflow 上找到的所有答案都在谈论如何生成抛出 android 应用程序的意图。
BUT thats not my case, i want to generate an href on a PHP/ASP server for an html page.
但那不是我的情况,我想在 PHP/ASP 服务器上为 html 页面生成一个 href。
someone? thanks!
有人吗?谢谢!
采纳答案by edan_develop
whatsapp now officially support url scheme over Android(Yey)!
whatsapp 现在正式支持 Android 上的 url 方案(是的)!
<a href="whatsapp://send?text=Hello%20World!">Hello, world!</a>
for more details visit http://www.whatsapp.com/faq/en/android/28000012
回答by kadir
Was working on the same Problem and found the solution:
正在处理相同的问题并找到了解决方案:
href="intent://send/[countrycode_without_plus][number]#Intent;scheme=smsto;package=com.whatsapp;action=android.intent.action.SENDTO;end
With a telephonenumber(+49 123 456 78)
有电话号码(+49 123 456 78)
href="intent://send/4912345678#Intent;scheme=smsto;package=com.whatsapp;action=android.intent.action.SENDTO;end
回答by Daniel Abril
I think the answer you where looking for is this:
我认为您正在寻找的答案是:
<a href="whatsapp://send?text=my message&phone=+XXXXXXXXXXX&abid=+XXXXXXXXXXX">Whatsapp me please</a>
This code works both in Android and iOS thanks to the parameters "phone" and "abid" respectively.
由于参数分别为“phone”和“abid”,此代码在 Android 和 iOS 中均可使用。
Sorry for the late response, hope it helps somebody anyway.
抱歉回复晚了,希望它对某人有所帮助。
回答by bsngr
Whatsapp url scheme working only saved ids or numbers for jump message send screen. Android working with message activity for new phone numbers.
Whatsapp url 方案只为跳转消息发送屏幕保存 ID 或数字。Android 处理新电话号码的消息活动。
This script Looking phone os and create link for phone os.
这个脚本寻找手机操作系统并为手机操作系统创建链接。
$(document).ready(function () {
if (matchMedia) {
var mq = window.matchMedia("(max-width: 991px)");
mq.addListener(WidthChange);
WidthChange(mq);
}
function WidthChange(mq) {
var isMobile = {
Android: function () {
return navigator.userAgent.match(/Android/i);
},
BlackBerry: function () {
return navigator.userAgent.match(/BlackBerry/i);
},
iOS: function () {
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
},
Opera: function () {
return navigator.userAgent.match(/Opera Mini/i);
},
Windows: function () {
return navigator.userAgent.match(/IEMobile/i);
},
any: function () {
return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
}
};
if (mq.matches) {
if (isMobile.Android()) {
$("a").attr("href", "intent://send/+905055555#Intent;scheme=smsto;package=com.whatsapp;action=android.intent.action.SENDTO;end");
} else {
$("a").attr("href", "tel:+905555555555");
}
};
}
});
回答by Ronierison
href="intent://send/4912345678#Intent;
scheme=smsto;
package=com.whatsapp;
action=android.intent.action.SENDTO;end
This will not work with iPhones.
这不适用于 iPhone。
回答by Morgan Koh
You can actually just easily create your own link and it will automatically handle it.
您实际上可以轻松地创建自己的链接,它会自动处理它。
Immediately, you can create a chat with the number without adding them in your contact book.
您可以立即与该号码进行聊天,而无需将其添加到您的通讯录中。
Here is if you just want to create a chat. 15551234567
is your phone number with your country code as prefix, don't include the + sign.
如果您只想创建聊天,请使用此处。15551234567
是您的电话号码,前缀是您的国家/地区代码,不要包含 + 号。
Here is if you want to include a pre-filled text message.
如果您想包含预填充的文本消息,请点击此处。
https://wa.me/15551234567?text=Hello There. General Kenobi!
https://wa.me/15551234567?text=你好。克诺比将军!
For more information, check out WhatsApp own documentation.
有关更多信息,请查看 WhatsApp 自己的文档。
回答by Hiren Modi
I used this href="intent://send/4912345678#Intent;scheme=smsto;package=com.whatsapp;action=android.intent.action.SENDTO;end
我用过这个 href="intent://send/4912345678#Intent;scheme=smsto;package=com.whatsapp;action=android.intent.action.SENDTO;end
but in this code cant include the text
但在此代码中不能包含文本