使用Unity为iOS和Android制作应用程序。
我现在陷入iOS问题:
You are using download over http. Currently unity adds `NSAllowsArbitraryLoads` to `Info.plist` to simplify transition, but it will be removed soon. Please consider updating to https.
不支持的网址
实际问题是:
- I connect to an https address
- I did set the Allow Arbitrary Loads to YES
然而,它没有用。
这是我的代码:
string GET = "mail="+mail+"&nome="+nome+"&cognome="+cognome;
// get parameters
WWW response = new WWW (SERVER+"adduser/?"+GET);
// calling page, address is like 'https://website.com/'
while (!response.isDone && response.error != "") {
yield return null;
}
if (response.error != "") {
print (response.error);
return false;
}
显然,这是在IEnumerator
函数中,它总是返回先前的错误。
答案 0 :(得分:3)
Apple停止在iOS设备上允许 http 连接。您仍然可以通过将NSAppTransportSecurity
添加到info.plist
来使用 http 连接,但将来会删除它。建议您从现在开始使用https连接。
UnityWebRequest
,通过将NSAppTransportSecurity
添加到info.plist
来自动解决此问题。
IEnumerator makeRequest()
{
string GET = "mail=" + mail + "&nome=" + nome + "&cognome=" + cognome;
UnityWebRequest www = UnityWebRequest.Get(SERVER + "adduser/?" + GET);
yield return www.Send();
if (www.isError)
{
Debug.Log("Error while downloading: " + www.error);
}
else
{
// Show results as text
Debug.Log(www.downloadHandler.text);
// Or retrieve results as binary data
byte[] results = www.downloadHandler.data;
}
}
请注意,如果您向NSAppTransportSecurity
添加info.plist
而对Apple没有正确解释,您的应用可能会被拒绝。同样,建议您升级服务器并使用 https 而不是 http 。