[英]ionic\cordova jsonp works in browser but not on ANDROID
i saw some similar questions but still didn't manage to find a solution. 我看到了一些类似的问题,但仍然没有找到解决方案。 the problem is as follows: 问题如下:
I have an html5 app which developed using Ionic. 我有一个使用Ionic开发的html5应用程序。
when i use 'ionic serve' my JSONP cross domain calls work as expected. 当我使用“离子服务”时,我的JSONP跨域调用按预期工作。 when i create the application using 'ionic build' and then install the application on my android phone using the apk i get 404 on my jsonp. 当我使用“ ionic build”创建应用程序,然后使用apk将应用程序安装在我的android手机上时,我在jsonp上得到404。
i altered the config.xml and added a child element to the element: 我更改了config.xml并向该元素添加了一个子元素:
<access origin="*" />
still the same result. 结果还是一样。
if i take the jsonp url and paste in the my phone Chrome i can see the result as expected - so no network issue. 如果我使用jsonp网址并将其粘贴到手机的Chrome中,则可以看到预期的结果-因此没有网络问题。
the communication is http (not secure) 通讯为http(不安全)
I assume i'm missing some configuration but can't figure out which. 我认为我缺少一些配置,但无法弄清楚。
I'll appreciate any kind of help. 我将不胜感激。 thanks in advance 提前致谢
I found the solution. 我找到了解决方案。 the steps are as follows: 步骤如下:
install cordova whitelist plugin from command line: 从命令行安装cordova白名单插件:
cordova plugin add https://github.com/apache/cordova-plugin-whitelist.git
add access tag to config.xml: 将访问标签添加到config.xml:
<access origin="*" />
I also had to remove the application completely and install it again. 我还必须完全删除该应用程序,然后重新安装。 not just overwriting. 不只是覆盖。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.