navigator.share does not work inside a Service Worker
Reported by
alastair...@guardian.co.uk,
Oct 27 2016
|
|||
Issue description
Device name: Sony Z5C
From "Settings > About Chrome"
Application version: Chrome Dev 56.0.2900.3
Operating system: Android 6.0.1
Steps to reproduce:
(1) Open web inspector for service worker, enter the following:
self.addEventListener("notificationclick", function() {navigator.share({
title: "Test share",
text: "Hello World",
url: "https://www.google.com"
}).then(() => console.log('Successful share'))
.catch((error) => console.log('Error sharing:', error));})
self.registration.showNotification("Test notification")
(2) Tap on notification that is shown
Expected result:
Share window appears
Actual result:
Error is returned: "navigator.share is not a function"
,
Oct 27 2016
Thanks for the bug report. This might be a simple matter of adding the share method to WorkerNavigator. I'll try and do this by Chrome 56.
,
Nov 28 2016
We're looking at this but there are some implementation problems: 1. Mojo is currently a bit broken on workers. It requires manual tracking of the origin (as is done in third_party/WebKit/public/platform/modules/permissions/permission.mojom) which is quite fiddly. It's possible but Mojo should just allow the response to be sent back to the correct renderer. 2. In Android, we need an Activity to send an intent. There might not be one, so we'd have to do something else to send the intent without a foreground page. We'll definitely want this so we'll keep trying but I think this is non-trivial. |
|||
►
Sign in to add a comment |
|||
Comment 1 by alastair...@guardian.co.uk
, Oct 27 2016