I recently built an Mac app using Unity3D,
In that we make network calls to a 3rd party server.
My Code in 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);
}
}
While developing and while QA it worked fine, In production build (set UseMacAppStoreValidation -> True) from Mac App store , it fails to work.
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>
Will any of you be able to help us figure out a reason for this? Any help would be greatly appreciated. Look forward to an expedited response.
- SOLUTION to above
Avoid using WWW, instead use HTTPWebRequest
This solved my problem.