Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

KaiOS - Share using WhatsApp

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?

like image 1000
julient-monisnap Avatar asked Jan 21 '20 11:01

julient-monisnap


2 Answers

You need to use the Web Activities API.

Activities defined for WhatsApp

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=.*)?)$"
        }
      }
    },
  }

Use activities to share

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" ]
  }
});
like image 172
Tom Avatar answered Oct 13 '22 18:10

Tom


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}`
  }
})
like image 1
julient-monisnap Avatar answered Oct 13 '22 17:10

julient-monisnap