Uncaught ReferenceError: PresentationRequest is not defined
hbmangal opened this issue · 5 comments
Hello,
I am always getting an error while trying to connect with the presentation request API.
const request = new PresentationRequest(presUrls);
It is always giving me the error:
Uncaught ReferenceError: PresentationRequest is not defined
Hi @hbmangal, I maintain the implementation in Chrome, and am happy to help.
- What browser / web engine are you using?
- Can you share the URL of the page you're testing, or more of the script?
Note that Presentation API is only available on secure contexts in Chrome (https: or file: URLs).
Hi @mfoltzgoogle, thanks for your reply.
Here are the details -
I am using Google Chrome & Firefox in the Ubuntu 18.04 with following versions:
Google Chrome Version 76.0.3809.132 (Official Build) (64-bit)
Firefox Quantum - 69.0 (64-bit)
I am following the reference - https://developer.mozilla.org/en-US/docs/Web/API/Presentation_API
Please see attached file I am using in my local.
present.txt
Hi,
Thanks for the pointer. The example code at that URL is out of date, I will try to contact the maintainers to fix that.
- What URL are you serving this from? I noticed you have http: IP addresses in the PresentationRequest. Those are not allowed because communicating from https: to http: is considered a mixed content situation.
Please try serving both the controlling and receiving page over https: or using Chrome's commandline flags to whitelist your origin:
--unsafely-treat-insecure-origin-as-secure=http://<host>:<port>
- Are you serving this file as HTML? I assume so, since you're seeing a JS exception.
Hi @mfoltzgoogle,
Thank you for the prompt response,
I am just creating a POC to validate the Presentation API for integrating into a project.
Yes, I am serving the file as HTML, for now, to check whether it works or not.
I have uploaded it to a secure origin and PresentationRequest worked.
Will you please tell me what are the browsers and versions the Presentation API would work smoothly?
Also, It would be very helpful if you can provide latest doc reference to refer.
Will you please tell me what are the browsers and versions the Presentation API would work smoothly?
Chrome has supported the Presentation API with normal HTML URLs since Chrome 59 (for desktop):
https://chromestatus.com/feature/5414209298890752
You can see support in other browsers on MDN, note I have not exhaustively tested this on all other browsers:
https://developer.mozilla.org/en-US/docs/Web/API/Presentation_API
Note, I'm planning on refreshing the mozilla.org documentation as it's a little behind the current spec.
Also, It would be very helpful if you can provide latest doc reference to refer.
The examples in the Presentation API spec should reflect the latest shipping implementation in Chrome: https://w3c.github.io/presentation-api/#examples
We also have a couple of sample apps if that would be helpful:
https://github.com/googlechrome/samples/tree/gh-pages/presentation-api
https://github.com/GoogleChromeLabs/presentation-api-samples
If you run into what looks like a bug with the Chrome implementation you can file a bug here and assign it to mfoltz@chromium.org:
https://bugs.chromium.org/p/chromium/issues/entry
Hope this helps. I'm going to close out this issue as it's not directly related to the spec itself.