"share_target" does not work in my PWA app

Viewed 420

I created a simple page with manifest.json (https://island-dapper-patella.glitch.me)

{
  "name": "Test",
  "theme_color": "#ff0000",
  "background_color": "#ff0000",
  "display": "fullscreen",
  "share_target": {
    "action": "/share.html",
    "params": {
      "title": "name",
      "text": "description",
      "url": "link"
    }
  }
}

I installed it on my smartphone (Android, Chrome 84), its icon appeared on the apps list.

But when I selected a text, and go to Share Menu I hadn't my PWA app there.

Why?

EDIT: Also I don't have an "Install" item in desktop Chrome. Maybe something is wrong?

1 Answers

I see your manifest.json missing some entries for share target.

Make sure it should be like this.

"share_target": {
"action": "url to get data",
"enctype": "multipart/form-data",
"method": "POST",
"params": {
  "title": "title",
  "text": "text",
  "url": "url",
  "files": [
    {
      "name": "media[]",
      "accept": [
        "audio/*",
        "image/*",
        "video/*"
      ]
    }
  ]
}

}

I am using this and it workes successfully. (yes with file uploading image, audio and video, you can add more mime types)

You need to make sure of following. The sharing should contain the name properly only then it will get the details.

"params": {
  "title": "name",
  "text": "description",
  "url": "link"
}

And you can conclude your test through this url : https://w3c.github.io/web-share/demos/share-files.html

Related