macos - 网络调用无法在使用 Unity3D 构建的发布版本 OSX 应用程序上运行

标签 macos unity-game-engine

我最近使用 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/

相关文章:

c# - TransformPoint() 方法附加到哪个对象的变换重要吗?

unity-game-engine - NavMesh 烘焙很快完成,并且不包含某些对象

android - 如何通过来自 3 个不同游戏对象的触发器使游戏对象出现

Swift - NSShadow 上的 shadowOpacity 在哪里?

objective-c - Cocoa:使用 Xcode 4.0 创建 iTunes/Sidebar 之类的东西

windows - 适用于 Windows 的自定义 USB 驱动程序?苹果电脑?

c# - Unity - 让对象消失一段时间然后再次显示

ios - 在 mac os 中使用 MBProgressHUD 显示 toast 消息

macos - macOS 上的 OpenSSL 1.0.2m

c# - 让 OnMouseDown 与 2D 多边形碰撞器一起使用