Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Websocket connection or importing packages #101

Open
mikobo opened this issue Jul 25, 2024 · 1 comment
Open

Websocket connection or importing packages #101

mikobo opened this issue Jul 25, 2024 · 1 comment

Comments

@mikobo
Copy link

mikobo commented Jul 25, 2024

Hi, I created my own background runner and it is working ok, with basic JavaScript. The problem starts when i need to connect using Websocket. I also tried to import some packages but i wont let me do it. Is there any option to bypass this problem, or some how run Websocket connection in background? Im running vite, Ionic 6, vue.

@theproducer
Copy link
Collaborator

theproducer commented Jul 25, 2024

Regarding importing packages in order to do Websockets (or other stuff): that will not work. As noted here: https://capacitorjs.com/docs/apis/background-runner#javascript-api

Background Runner does not execute your Javascript code in a browser or web view, therefore the typical Web APIs you may be used to may not be available. This includes DOM APIs nor ability to interact with your application's DOM.

Most packages assume they are running in the browser with the full suite of WebAPIs available, but that's not the case here. I assume any Websocket package you are trying to use is expecting https://developer.mozilla.org/en-US/docs/Web/API/WebSocket to be available, but its not currently in the runtime.

Adding Websocket support is something I can definitely look into adding some time in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants