4

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.

5
  • a real annoyance when going to a URL is that, in practice, you have to add a random seed on the end of the URL to defeat the endless layers of caching involved in fetching something. could this be the issue?
    – Fattie
    Apr 6, 2016 at 14:02
  • I wish I could help but I'm actually commenting to say that I've seen this issue too. Last build of my app things in mac store were fine, now my network connections are getting no where. Have you installed a more recent version of OS X or something, thats the difference between this release and the last that went through without issue. Apr 7, 2016 at 4:44
  • @AlexTheMighty, I have the same issue. I'm using Unity 5.3.4p1 and everything works fine while developing, but once I turn on mac app store validation and wait for it to come out of Apple review, the network calls fail to work. Have either of you been able to find a workaround? May 10, 2016 at 14:06
  • @Alfa, did you ever find a solution for this? I'm having the same problem. May 10, 2016 at 14:06
  • Ya, The problem is with the WWW, Instead use HTTPWebRequest
    – Alfa
    May 13, 2016 at 10:50

1 Answer 1

-1

Maybe you are trying to access a non-secure URL, and it's now prohibited in Android 9

1
  • This is related to macOS not Android.
    – Alfa
    Feb 27, 2020 at 9:02

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.