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

感情迁移 提交于 2019-12-29 09:17:35

问题


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.


回答1:


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.

  • http://yourdomain.com will give you this error.
  • https://yourdomain.com will NOT give you this error and is what Apple recommends 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.



来源:https://stackoverflow.com/questions/39296567/you-are-using-download-over-http-currently-unity-adds-nsallowsarbitraryloads-to

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!