New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 660020 link

Starred by 4 users

Issue metadata

Status: Assigned
Owner:
Long OOO (go/where-is-mgiuca)
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 2
Type: Feature



Sign in to add a comment

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"

 
I should have clarified in the title - this is in response to a notificationclick event only, similar to the "user gesture" restriction placed on the API in a browser context.

Comment 2 by mgiuca@chromium.org, Oct 27 2016

Cc: sa...@chromium.org
Components: Blink>WebShare
Labels: -Pri-3 M-56 Pri-2 Type-Feature
Owner: mgiuca@chromium.org
Status: Assigned (was: Unconfirmed)
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.

Comment 3 by mgiuca@chromium.org, Nov 28 2016

Labels: -M-56 M-57
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