w3c / presentation-api

Presentation API
https://www.w3.org/TR/presentation-api/
Other
71 stars 39 forks source link

Cannot find name 'PresentationRequest' #510

Closed abutizi closed 1 year ago

abutizi commented 1 year ago

Dear amazing team, I'm using Angular with Ionic. I'm trying to implement Presentation API. However, it seems like I either have to import Presentation library or install it somehow. Any ideas?

Anyone have any experience with this library and Angular/ionic and are willing to share?

const presentationRequest = new PresentationRequest(); Cannot find name 'PresentationRequest'....

anssiko commented 1 year ago

(This is slightly off topic for a spec repo, but I'll try to offer some direction to help you forward.)

@abutizi Thank you for your interest toward the Presentation API!

I'm not familiar with Ionic, but it looks like the runtime (called Capacitor, using WebView) underneath the UI layer (Ionic) hosts the app files from a local HTTP server served with the http:// protocol. The reason you're hitting that error is likely two-fold: the PresentationRequest API is only exposed if the app files are served with the https:// protocol. Secondly, the Presentation API is not enabled in WebView see e.g. https://crbug.com/521319. There seems to be a proposal in https://github.com/capacitor-community/proposals/issues/139 for a Capacitor plugin to enable this API, but no movement yet, so not helping you.

All is not lost. Depending on your use case, you may want to develop a regular web app or a PWA instead. If you want to pursue this path, to get you going, please first check you are using a compatible web browser and then try this demo.

@mfoltzgoogle may be able to speak briefly on the feasibility of supporting Presentation API in Android WebView.

markafoltz commented 1 year ago

Hi @abutizi, you can track the progress of Presentation API on WebView in the Chromium issue tracker:

https://crbug.com/521319

I have asked the WebView team for an update and if I hear anything I can post in the tracker I will update the ticket.

If the API is important for your application and you can't wait for possible future WebView compatibility, then I would suggest building a PWA in a compatible browser as suggested by Anssi. If you run into issues with your PWA that look like bugs or missing features then I can try to direct your inquiry.

Thanks for your question, I am closing this issue as further WebView updates can be found at the link above.