Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.4k views
in Technique[技术] by (71.8m points)

c# - You are using download over http. Currently Unity adds NSAllowsArbitraryLoads to Info.plist to simplify transition

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...