我正试图为KaiOS开发一个应用程序,在那里我想和WhatsApp分享短信。
我试过使用深链,比如:
app://whatsapp/sendwhatsapp://send两个人都没用。
有人知道如何与WhatsApp共享内容吗?
发布于 2021-02-11 08:27:07
多亏了KaiOS和Whatsapp团队,我终于发了一条短信。这就是做这个的方法:
const phoneNumber = "0123456789"
const urlEncodedMessage = "SentFromKaios"
const sendTextMessageActivity = new MozActivity({
name: "view",
data: {
type: "url",
url: `https://wa.me/${phoneNumber}?text=${urlEncodedMessage}`
}
})发布于 2021-02-09 23:58:17
您需要使用Web活动API。
为WhatsApp定义的活动
WhatsApp公开了两个主要活动:
shareview见WhatsApp的manifest.webapp
"activities": {
"share": {
"href": "/notification.html",
"filters": {
"type": [
"video/*",
"image/*",
"text/vcard",
"text/plain"
]
}
},
"view": {
"href": "/notification.html",
"filters": {
"type": "url",
"url": {
"required": true,
"pattern": "^https://(?:chat\\.whatsapp\\.com/(?:invite/)?[0-9A-Za-z]+|wa\\.me/[0-9]+(?:\\?text=.*)?)$",
"patternFlags": "i",
"regexp": "^https://(?:chat\\.whatsapp\\.com/(?:invite/)?[0-9A-Za-z]+|wa\\.me/[0-9]+(?:\\?text=.*)?)$"
}
}
},
}利用活动共享
要使用WhatsApp共享文本消息,可以使用预定义的活动名称实例化MozActivity。
像这样的东西应该可以在应用程序或web上下文中工作。
var pick = new MozActivity({
name: "share",
data: {
type: "text/plain",
blobs: [ "This is a message to share via WhatsApp" ]
}
});https://stackoverflow.com/questions/59840271
复制相似问题