gpt4 book ai didi

ios - Cordova HttpClient 调用在 IOS 设备中失败但在 Android 设备中有效

转载 作者:行者123 更新时间:2023-11-29 11:31:32 26 4
gpt4 key购买 nike

我知道之前有人问过这个问题 HTTPS request fails only on iOS, Ionic 2但这些答案对我不起作用。

我已经在 ios xcode10 项目的 [myproject]-info.plist 文件中进行了以下设置

<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>

我的项目中没有安装 wkwebview 插件 here ,而是在我的项目中安装了 ionic-webview-plug。

端点是托管在 Windows 服务器中的 MVC Controller 操作方法。我无法像在 Android 测试中那样使用 chrome://inspect 从 Windows 调试 IOS 应用程序。虽然应用程序能够访问其他静态链接,例如图像,但此 Web 服务调用失败。

在下面的 Angular 代码中是如何使用 HttpClient 进行 Web 服务调用的

var oDat = {
uuid: uuid
};
let headers = new HttpHeaders();
headers = headers.set(‘Content-Type’, ‘application/json; charset=utf-8’);
return this.http.post(this.apiUrl23, JSON.stringify(oDat), {headers: headers}).pipe(
map(this.extractData),
catchError(this.handleError)
);

下面是一个从页面触发的订阅者代码

  this.horoService.getPlan(this.device.uuid)
.subscribe(res => {
this.info2 = '';
let pln: Plan = { uuid: res['uuid'], name: res['name'], credits: res['credits'], dobs: res['dobs'] };
this.plan = pln;
if(res['name'] == 'xxx.xxx.xxx.xxx'){
this.showSU = true;
this.showCR = false;
this.showASU = false;
} else if(Number(res['credits']) == 0) {
this.showSU = false;
this.showCR = true;
this.showASU = false;
} else {
this.showSU = true;
this.showCR = false;
this.showASU = true;
}
}, (err) => {
this.showSU = false;
this.showCR = false;
this.showASU = false;
this.info2 = JSON.stringify(err);
});

下面是我项目中使用的Cordova版本

Ionic:
ionic (Ionic CLI) : 4.2.1 (C:\Users\Hamsini\AppData\Roaming\npm\node_modules\ionic)
Ionic Framework : ionic-angular 3.9.2
@ionic/app-scripts : 3.2.0

Cordova:

cordova (Cordova CLI) : 8.0.0
Cordova Platforms : android 6.3.0, ios 4.5.5
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.2, cordova-plugin-ionic-webview 1.2.1, (and 12 other plugins)

构建是在 xCode10 上进行的,并在 ipad 版本 9.3.5 上进行了测试

有什么猜测吗?

UPDATE-30/10当我使用 ionic serve 运行时,我可以看到 HTTPResponse 正确返回,但随后在 .subscribe (err) 处理程序中它显示未知 URL、未知错误

最佳答案

我正在回答我自己的问题,因为这可能会对某人有所帮助。

问题似乎与 downgrading to UIWebView 之后的 WKWebView 有关似乎解决了

在 Cordova 解决问题之前,目前需要执行以下步骤

post关于 xCode10 和 Cordova 兼容性问题非常详细,自推出以来已经有一段时间了,但 Cordova 家伙还没有提出解决方案,解决方法是在构建过程中忽略新架构,涉及 iOS 的部署过程很少复杂,因为它更依赖于 XCode 和 MAC 平台,所以在使用以下命令行构建之后

ionic cordova build ios -- --buildFlag="-UseModernBuildSystem=0"

您还必须确保在 xCode build设置中选择“Legacy Build System”,如图所示 herehere

但是由于此降级可能会产生其他副作用,例如在应用程序中点击 SVG 图像的某些部分无法正常工作,这在 Android 设备上是有效的,偶数监听器是动态附加的,不确定如果这是由于降级 if not just works for iOS devices because I haven't tested this App before any other iOS devices

关于ios - Cordova HttpClient 调用在 IOS 设备中失败但在 Android 设备中有效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53052464/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com