我最近使用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);
}
}
在进行开发和质量检查的同时,
在Mac App store的生产版本(将UseMacAppStoreValidation设置为True)中,它无法工作。
Mac应用是
-沙盒
-添加了用于访问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
这解决了我的问题。
最佳答案
也许您正在尝试访问不安全的URL,但现在在Android 9中已禁止使用