making an app for both iOS and Android with Unity.
I'm now stuck on an iOS problem:
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.
unsupported URL
The actual problem is:
- I connect to an https address
- I did set the Allow Arbitrary Loads to YES
Yet, it's not working.
Here's my code:
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;
}
obviously, this is in a IEnumerator
function and it ALWAYS returns the previous error.
Apple stopped allowing http connections on iOS devices. You can still use http connection by adding NSAppTransportSecurity
to the info.plist
but this will be removed in the future.It is recommended that you use https connection from now.
UnityWebRequest
was introduced to automatically solve this problem by adding NSAppTransportSecurity
to the 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;
}
}
Note that your app may be rejected if you add NSAppTransportSecurity
to the info.plist
without good explanation to Apple. Again, it is recommended that you upgrade your server and use https instead of http .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.