【发布时间】:2020-03-04 14:06:47
【问题描述】:
我们有一个 IONIC 应用程序,我们在其中调用外部服务女巫发布带有数据的 JSON 对象。
当我们通过 > ionic serve 执行 de app 时,在浏览器上一切正常,但是当我们尝试在模拟器上执行时,执行 get 后什么都没有发生。
我们称之为:
//we pop a message just here, and the device shows it.
this.http.get('https://ourExternalSite.com/getData').subscribe(data => {
//do things. We put here a message that never pops
}, error => {
//do things, we also put here a message, that never pops neither
});
我们检查了设备上的https://ourExternalSite.com/getData url,完全可以访问并显示 JSON 对象。
我们不是 IONIC 方面的专家,此应用是由分包商开发的,我们正在尝试将其集成到我们的环境中。
编辑:我尝试将 network_security_config.xml 文件添加到项目中,正如这些答案所建议的那样:Http.get() working but not working in build(Release/Debug) in Ionic 4 Ionic Native HTTP does not work for Anroid 9 (Pie) and up?
但没有任何改变
EDIT2:好的,我缩小了问题的范围。必须使用 https,如果我将调用更改为 http 请愿书,一切正常!
所以我想我需要在 network_security_config.xml 文件中启用 https 调用
任何帮助将不胜感激。
【问题讨论】:
-
@NajamUsSaqib 很遗憾,这不能解决问题
-
我们使用的是 Ionic 3
-
其实Android改变了它的HTTP系统。我确定您遇到的问题与我在上述帖子中回答的问题相同。您可以创建
network_security_config.xml。检查这个答案:stackoverflow.com/a/56801007/5909026
标签: android cordova http ionic-framework get