I have the following snippet on my web manifest manifest.webmanifest
:
"share_target": {
"action": "/",
"method": "GET",
"params": {
"url": "dirtyurl",
"title": "title",
"text": "bodyText"
}
}
So I'd expect that when a user selects the app in the share tray I'd get something like https://mywebsite.com/?dirtyurl=someurl&title=titleofarticle&bodyText=textofsomething
, right? But when I display window.location.href
on the website I get just https://mywebsite.com/
.
Since this is an PWA installed on Android, I can't really see the dev tools to see if any error was posted. And for some reason the app doesn't show on the Windows 11 share tray at all so I cannot check on my computer's debug tools.
So, why is the Web Share Target API property not working as intended? I have been trying to follow the MDN guide here: https://developer.mozilla.org/en-US/docs/Web/Manifest/share_target but I can't find any reason why the URL isnt being populated as it should.
Thank you!
I've been struggling with the same problem and what kind of worked for me is having manifest part like this:
"share_target": {
"action": "/Link/SharedLink/",
"method": "GET",
"params": {
"title": "name",
"text": "description"
}
}
Where action is my controller method.
And my controller is like this:
public ActionResult SharedLink(string name, string description)
{
ViewBag.Name = name; // this will contain page title
ViewBag.Description = description; // this will contain page URL
return View("SharedLink");
}
I don't know why there is an apparent mix-up with the names, but that's what worked.