I'm trying to develop an app for KaiOS where I want to share text messages with WhatsApp.
I tried with deep-links like:
app://whatsapp/send
whatsapp://send
Both didn't work.
Does anyone know how share content with WhatsApp?
You need to use the Web Activities API.
There are two main activities exposed from WhatsApp:
share
view
See WhatsApp's 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=.*)?)$"
}
}
},
}
To share a text message using WhatsApp, you could instantiate MozActivity
using the pre-defined activity names.
Something like this should work either from an app or web context.
var pick = new MozActivity({
name: "share",
data: {
type: "text/plain",
blobs: [ "This is a message to share via WhatsApp" ]
}
});
I've finally managed to send a text message thanks to KaiOS and Whatsapp teams. This is the way to do it :
const phoneNumber = "0123456789"
const urlEncodedMessage = "SentFromKaios"
const sendTextMessageActivity = new MozActivity({
name: "view",
data: {
type: "url",
url: `https://wa.me/${phoneNumber}?text=${urlEncodedMessage}`
}
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With