Anyone using socket.io-client ? Do you face any problem on iOS 10?
For me everything work like on charm on Android and iOS <= 9. On iOS 10 I can’t establish a connection. Do I make something wrong or do I miss something?
this.socket = io.connect(Resources.Constants.API.SERVER_DOMAIN, {
'transports': ['websocket', 'xhr-polling'],
'query': 'token=' + myToken
});
alert('test:' + this.socket.id); // undefined
alert('test:' + this.socket.connected); // false
Any help would be much appreciated!
It turns out that last Safari is more picky about CSP than the others.
Adding ws://* wss://* to my connect-src in my Content-Security-Policy solved my issue.
<meta http-equiv="Content-Security-Policy" content="default-src data: gap://* file://* https://ssl.gstatic.com *; img-src 'self' * data:; style-src 'self' 'unsafe-inline' *; script-src 'self' 'unsafe-eval' 'unsafe-inline' *; connect-src 'self' * ws://* wss://*;">
roject
October 14, 2017, 1:04pm
3
i am getting the same issue. working fine in web. but not in iPhone.
I install it as an app. added the Content-Security-Policy into index.html doesn’t help .
any other ideas?
For me I found the solution while testing it in Safari instead as Chrome as I mostly do…does it work for you when you debug locally in Safari?
roject
October 15, 2017, 6:37am
5
working good in browser. but not the app.
getting the same in app:
alert(‘test:’ + this.socket.id ); // undefined
alert(‘test:’ + this.socket.connected); // false
where do you put the Content-Security-Policy in ?
Are you 100% sure it’s a CSP issue? Have you try to remove it and to test your app on your phone without it?
Have you added some debug logs on your server side? Do you see the connection request there?
bevin
February 17, 2022, 2:03pm
7
hi ReedRichards, lm need your assistance on deploying IOS to connect to socket io on Heroku server please. I have managed to do so on Android its all working only on IOS is the issue.
Thanks in advance
Cannot help, it’s been like 4 years old, got no clue anymore . good luck