Socket.io in ionic cordova [英] Socket.io in ionic cordova
问题描述
最初我已经为我的离子项目使用了btford socket.io库,但是我在使用它时遇到了麻烦。现在我尝试将socket.io直接安装到离子项目中。但是我不确定它是否应该安装为将它存储在node_modules文件夹中的npm安装,还是应该将该库存储在ionicprj / www / lib中?
Initially I have used btford socket.io library for my ionic project, but I am having trouble working with it. Now I am trying to install socket.io directly to an ionic project. However I am not sure whether it should installed as an npm install which will store it in the node_modules folder, or should i store the library in ionicprj/www/lib ?
推荐答案
cordova-plugin-whitelist 目前似乎是强制性的。
cordova-plugin-whitelist seems to be "mandatory" at present.
安装
cordova plugin add cordova-plugin-whitelist
配置config.xml
您可以将当前设置保留为*或更改以获得更严格的规则
You can keep your current setup with * or change for more restrictive rules
在index.html上添加html 政策,您还应添加政策。要授权一切,这里是:
add a html policy on index.html, you shall add a Policy also. To authorise everything, here it is :
<meta http-equiv="Content-Security-Policy" content="default-src *;
style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe eval'">
这篇关于Socket.io in ionic cordova的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!