gpt4 book ai didi

ios - 如何允许应用程序在 ios 上访问互联网?

转载 作者:行者123 更新时间:2023-11-28 19:26:10 25 4
gpt4 key购买 nike

我的 Nativescript 应用程序在 Android 上运行良好,但在 iOS 上无法连接到互联网。安装或模拟。

这是我的商店(我使用互联网的地方):

import Vue from 'vue';
import Vuex from 'vuex';
import axios from 'axios/dist/axios';

const api = axios.create({
baseURL: 'http://asdfasdf.compute.amazonaws.com',
timeout: 2000,
});

Vue.use(Vuex);
export default new Vuex.Store({
strict: process.env.NODE_ENV !== 'production',
state: {
name: null,
err: null,
},
mutations: {
initialize(state, name) {
state.name = name;
},
err(state, txt) {
state.err = txt;
},
},
actions: {
init({commit}) {
api
.get('/name/')
.then(response => {
commit('initialize', response.data);
})
.catch(function(error) {
commit('err', error);
});
},
},
});

我在我的 android 安装上很好地加载了名称,但是在 ios 模拟器和 iPhone 安装上我得到:

Error: Request failed with status code null

有什么办法可以解决这个问题吗?我在任何地方都没有收到任何错误或异常,如果我将手机与互联网断开连接,我也会收到完全相同的错误。我没有使用任何代理。

最佳答案

一个可能的问题是 ATS 你可以阅读 here

您需要做的是将以下代码片段添加到 app/App_Resources/iOS/Info.plist 中.有一个 <dict>里面有很多内容的标签。你需要做的就是把这个放在那个里面 <dict>

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

所以你会得到这样的东西:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
# snippet goes here
.
.
.
</dict>
</plist>

如果您的服务器使用的是自签名证书,您也需要这样做。

关于ios - 如何允许应用程序在 ios 上访问互联网?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57271847/

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