w3c / window-management

Window Management API
https://www.w3.org/TR/window-management/
Other
96 stars 25 forks source link

Support for Android (permission denied - no prompt) in PWA (TWA) #144

Closed fryck closed 6 months ago

fryck commented 6 months ago

Hi !

I'm currently building a PWA (packaging in apk file - with TWA) that works great, BUT I try to use window-management API inside my PWA, when I try to access window.getScreenDetails(), I got a "permission denied" without any prompt to grant permission.

I tried to ask permission before calling the function with:

<button
          onClick={async () => {
            try {
              const permissionResult = await navigator.permissions.query({
                name: "window-management",
              });
              if (permissionResult.state === "granted") {
                const screendetails = await window.getScreenDetails();
                console.log(screendetails);
              } else {
                console.log("Permission for window-management not granted");
              }
            } catch (error) {
              console.error(
                "Error requesting window-management permission or getting screen details: ",
                error
              );
            }
          }}
        >
          Open
        </button>

But same result, no prompt is shown. I tried to force Permissions-policy: window-management=self in HTTP request headers too, but it still not working, do you have any suggestions ?

I run PWA in android (13) emulator (maybe it's because of that) and try to emulate external extended monitor.

(Chrome version 123)

Thanks !

michaelwasserman commented 6 months ago

Chrome for Android does not yet support the API; feel free to comment on the issue I filed there, thanks!

fryck commented 6 months ago

So sad.... It would be very useful for my project... :(

michaelwasserman commented 6 months ago

Please do advocate for support on that Chromium issue, and share use cases if you're able.

anssiko commented 6 months ago

@fryck your project sounds interesting. A helpful specification contribution from you would be a short description of your use case to help raise excitement and prioritize Android implementation. A one line description is enough, see the current use cases: https://www.w3.org/TR/window-management/#motivations

This repo is for specification discussions. To track and comment Android implementation: https://issues.chromium.org/331370720

Thank you for trying out this API. It is not always obvious where to send feedback, so no worries.

fryck commented 6 months ago

Hi ! Thanks for your feedback, here is my use case:

I'll open a darts venue soon in Lille (France) with 6 darts lane, this is a new interactive darts technology (traditional dartboard - steel dart - with auto-scoring).

Each lane have a screen on top of dartboard which display the game screen, and one table (customer side) to manage players lobby, game selection etc, once user have selected game, I need to open the game screen on the external monitor, and on the tablet another app view to manage score correction and other information.

Another crucial point in my case: I don't want message like "You are in fullscreen mode, press esc to exit" in the extended monitor, I don't know if it's possible to add policy for trusted domain to bypass this message which degrade customer experience in a commercial environment use.

Setup example:

IMG_2294-scaled

Many Thanks !

anssiko commented 6 months ago

@fryck that's an exciting and a unique use case! And a lot of fun I'm sure. I may be biased, I have a dartboard :-)

Chrome dev rel folks e.g. @beaufortfrancois working in the related space may want to put this idea on the back burner as things the web could do -- please check out the use case and the image of the setup: https://github.com/w3c/window-management/issues/144#issuecomment-2022395339 ☝️

I think this darts use case is very demo-worthy. Think presenting about this API at developer-facing events, this use case illustrated as above would definitely break the ice. Or, even more cool, have a darts tournament powered by this Web API at a web developer event -- unlimited opportunities for more fun!

@michaelwasserman that picture is worth a thousand words. How to integrate this into use cases without losing the fun factor?

fryck commented 6 months ago

Thanks @anssiko !

I really appreciate the guidance and am keenly interested in the further development of the window-management API (as it's been quiet since July 2023). It holds great potential for projects like mine.

In the meantime, are there any suggested workarounds or alternative approaches to achieve similar functionality?

Your advice would be invaluable.

michaelwasserman commented 4 months ago

I shared michael@s57.io's recap on the Chromium implementation issue: Window Management: Support for Android. Unfortunately, their work has been halted due to shifting priorities.

The same PWA should be able to use Window Management APIs for this use case on other OSes.

anssiko commented 4 months ago

@michaelwasserman thanks for the transparent update, much appreciated.

@fryck if you do further experimentation on this API on currently supported OSes and run into issues that you feel are related to spec capabilities or functionality, feel free to report them to us. Sometimes it is not obvious whether an issue is an implementation or a spec bug, so we can redirect you to the right place if you're unsure.