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

new Socket() fails #36

Open
RatijitMitra opened this issue Apr 16, 2017 · 3 comments
Open

new Socket() fails #36

RatijitMitra opened this issue Apr 16, 2017 · 3 comments

Comments

@RatijitMitra
Copy link

As per the given instruction, I have installed the plugin and then written a function in app.js that contains -
var v = new Socket();

When I run my app using 'ionic serve', I get the following error in Chrome browser -
ReferenceError: Socket is not defined

Could anybody find my mistake? Any help would be highly appreciated...

@LionOpeter
Copy link

I am facing the same problem.
Any solution for this?

@sontono
Copy link

sontono commented Jun 15, 2017

I can create and use a socket with following code in a function:
let socket = new (<any>window).Socket();
but, if I am not able to declare and initialize a socket global variable. For example, this code in my class constructor:
var socket = new (<any>window).Socket();
gives following error:

Uncaught (in promise): TypeError: window.Socket is not a constructor

@sontono
Copy link

sontono commented Jun 16, 2017

I have found the reason to the fail reported in my previous comment: code runs ok when app is launched in an Android device, but it fails when using "ionic serve" to run on browser. I have noticed that this plugin is declared to NOT work on browser environment, so I think everything is OK with this issue.

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

3 participants