简体   繁体   English

ionic \\ cordova jsonp可在浏览器中使用,但不适用于ANDROID

[英]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.

相关问题 Ionic Cordova AngularJs:为什么Facebook共享可以在Ionic服务(浏览器)中工作,但不能在Android Device中显示弹出窗口? - Ionic Cordova AngularJs : Why Facebook share works in Ionic serve (browser) but not pop-up display in Android Device? Cordova项目可在浏览器上工作,但不能在android中 - Cordova project works on browser but not in android 爱奥尼亚·科尔多瓦(Ionic Cordova)$ http POST数据在浏览器中效果很好,但在我的Android手机中不起作用 - Ionic Cordova $http POST data works well in browser but does not work in my android phone Ionic Cordova SQLite在浏览器上运行良好,但在Android设备上无法持久运行 - Ionic Cordova SQLite works well on browser but does not work persistent in Android device 科尔多瓦/离子如何工作? - How cordova/ionic works? Cordova (Ionic) : Splashscreen 在 Android 上只能工作一次 - Cordova (Ionic) : Splashscreen only works one time on Android 混合android cordova离子 - hybrid android cordova ionic 离子科尔多瓦建立Android - ionic cordova build android Android 上的 reCAPTCHA Ionic/cordova - reCAPTCHA Ionic/cordova on Android 带有cordonic-android@8.0.0的Ionic 4问题,带有Ionic服务,效果很好,但在设备上屏幕只是一片空白 - Ionic 4 problem with cordova-android@8.0.0, with Ionic serve works fine, but on device the screen just goes blank
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM