unity ios 使用 https 无法进行休息标注

unity ios using https unable to make rest callout

我能够在 android 和 unity 编辑器上毫无问题地使用 https 获取标注,但它在 ios 上不起作用。请注意,url 使用的是 HTTPS,而不是 HTTP。尝试连接到 xcode 时,出现以下错误。

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.
NSURLConnection finished with error - code -1002

根据我的阅读,似乎需要编辑 plist 以允许此连接,但我不确定该怎么做。我的 plist 编辑代码目前看起来像:

[PostProcessBuild]
static void OnPostprocessBuild(BuildTarget buildTarget, string path)
{
    // Read plist
    var plistPath = Path.Combine(path, "Info.plist");
    var plist = new PlistDocument();
    plist.ReadFromFile(plistPath);

    // Update value
    PlistElementDict rootDict = plist.root;
     rootDict.SetString("NSPhotoLibraryAddUsageDescription", "Used for saving high score screenshots");
    rootDict.SetBoolean("NSIncludesSubdomains", true);
    rootDict.SetBoolean("NSTemporaryExceptionAllowsInsecureHTTPLoads", true);
    rootDict.SetString("NSTemporaryExceptionMinimumTLSVersion", "TLSv1.1");

    // Write plist
    File.WriteAllText(plistPath, plist.WriteToString());
}

上的最佳答案给出了编辑 plist 的解决方案,但我不确定我是否通过 unity 正确地完成了它。我还尝试手动编辑 xcode 中的 plist,但仍然没有用。我也不确定这是否是问题,所以任何其他建议将不胜感激。

编辑:使用 xcode 版本 9.4 和 Unity 版本 2018.1.2f1 个人版。标注的代码(其中之一)如下:

IEnumerator getHighscores() {
    loadingObject.SetActive(true);
    string username = GameManager.loggedInUser;
    using (UnityWebRequest request = UnityWebRequest.Get(Constants.uriBase + "/scores?username=" + username + "&apiKey=" + Constants.apiKey)) {
        yield return request.SendWebRequest();
        loadingObject.SetActive(false);
        if (request.isNetworkError) {
            ErrorMessage.text = "Unable to connect"; //THIS IS THE OUTCOME OF THE IOS CALLOUT
            ErrorMessage.enabled = true;
        } else if( request.isHttpError) {
            if(request.responseCode == 406) {
                string modifiedResponse = request.downloadHandler.text.Replace("\"", "");
                ErrorMessage.text = modifiedResponse;
                ErrorMessage.enabled = true;
            } else {
                ErrorMessage.text = "Unknown Error";
                ErrorMessage.enabled = true;
            }
        } else {
            ErrorMessage.enabled = false;
            string jsonResponse = request.downloadHandler.text;
            //process successful response here
        }
    }
}

我明白了。问题是 url 包含一个 % 符号,而 ios 显然无法处理。