我最近使用 Unity3D 构建了一个 Mac 应用程序,
我们对第三方服务器进行网络调用。
我的 Unity C# 代码:
void someFunc(){
Dictionary<string, object> jsonDict = new Dictionary<string, object>();
jsonDict.Add("$Param1", Token);
jsonDict.Add("$Param2", DistinctID);
jsonDict.Add("$Param3", propsDict);
string jsonStr = JsonMapper.ToJson(jsonDict);
if(EnableLogging)
Debug.Log("Sending data: " + jsonStr);
string jsonStr64 = EncodeTo64(jsonStr);
string url = string.Format(API_URL_ENGAGE, jsonStr64);
StartCoroutine(SendDataCoroutine(url));
}
IEnumerator SendDataCoroutine(string url)
{
WWW www = new WWW(url);
yield return www;
if (www.error != null) {
Debug.LogWarning ("Error sending Data: " + www.error);
}else if (www.text.Trim () == "0") {
Debug.LogWarning ("Error on processing Data: " + www.text);
} else if (EnableLogging) {
Debug.Log ("processed Data: " + www.text);
}
}
在开发和 QA 过程中,它运行良好, 在 Mac App store 的生产版本(设置 UseMacAppStoreValidation -> True)中,它无法工作。
Mac app is
- Sandboxed,
- Entitlements added for accessing NETWORK_CLIENT, CAMERA, USER_SELECTED_FILES.
Entitlement File:
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.device.camera</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
</dict>
你们中有人能帮我们找出原因吗? 任何帮助将不胜感激。期待快速回复。
- 上述解决方案
避免使用 WWW,而是使用 HTTPWebRequest
这解决了我的问题。
最佳答案
也许您正在尝试访问不安全网址,而 Android 9 中现已禁止这样做
关于macos - 网络调用无法在使用 Unity3D 构建的发布版本 OSX 应用程序上运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36446063/