2016-03-17 21 views
5

我有一个应用程序内置Unity和安装程序将在Mac App Store上发布,该应用程序的网络任务在OS X版本中工作得很好,但不适用于应用商店,但是一旦需要应用商店验证/编码的构建发生,联网就会失败。该应用程序和构建过程不久前就开始工作,但现在失败了。OSX Mac商店应用程序网络在codesign/package后失败

我在授权中包含网络权限,并且在系统控制台中没有看到沙箱错误的任何跟踪。应用内购买联网呼叫成功,但如果我检查终端中的其他任何流量,则没有数据移入或移出。

所以我想知道是否有人有什么想法可能导致这个或进一步的测试,我可以用来找出问题可能是什么。

+0

你使用什么插件?你在xcode中添加了什么框架?什么是网络任务?简单的json查询或套接字或什么?请详细说明以增加获得支持的机会,并使我们更容易帮助您。 – DeyaEldeen

+0

唯一的插件是Unity IAP,没有通过Xcode添加框架(真的不使用Xcode)。网络我试图连接到解析,但我也尝试了简单的WWW调用测试网站,没有任何事情正在通过。 – AlexTheMighty

+0

@AlexTheMighty我遇到了使用Unity 5.3.4p1的相同问题。你有没有找到解决方案? –

回答

0

我从来没有想过出了什么问题Unity的WWW类,但我能够解决使用System.Net.WebClient类的问题。我实现了一个与Unity的WWW类具有相似接口的简单包装。这里是我使用的代码:

using System; 
using System.Net; 
using System.Net.Security; 
using System.Text; 

/// <summary> 
/// Web request using the WebClient class. 
/// </summary> 
/// <seealso cref="Assets.Scripts.WebRequest" /> 
internal class WebRequest 
{ 
    /// <summary> 
    /// The web client. 
    /// </summary> 
    private WebClient _client; 

    /// <summary> 
    /// The error message. 
    /// </summary> 
    private string _error; 

    /// <summary> 
    /// The is done flag. 
    /// </summary> 
    private bool _isDone; 

    /// <summary> 
    /// The progress. 
    /// </summary> 
    private float _progress; 

    /// <summary> 
    /// The text. 
    /// </summary> 
    private string _text; 

    /// <summary> 
    /// Initializes a new instance of the <see cref="WebRequest"/> class. 
    /// </summary> 
    /// <param name="url">The URL.</param> 
    public WebRequest(string url) 
    { 
     this._client = new System.Net.WebClient(); 
     this._client.DownloadProgressChanged += this.WebClientProgressChanged; 
     this._client.DownloadStringCompleted += this.WebClientDownloadCompleted; 
     this._client.DownloadStringAsync(new Uri(url)); 
    } 

    /// <summary> 
    /// Initializes a new instance of the <see cref="WebRequestDotNet"/> class. 
    /// </summary> 
    /// <param name="url">The URL.</param> 
    /// <param name="form">The form.</param> 
    public WebRequest(string url, UnityEngine.WWWForm form) 
    { 
     this._client = new System.Net.WebClient(); 
     this._client.UploadProgressChanged += this.WebClientUploadProgressChanged; 
     this._client.UploadDataCompleted += this.WebClientUploadCompleted; 

     this._client.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded"; 

     // Try to get the header from the Unity form 
     foreach (var header in form.headers) 
     { 
     const string ContentType = "Content-Type"; 
     if (header.Key == ContentType) 
     { 
      string contentType = header.Value; 
      this._client.Headers.Remove(ContentType); 
      this._client.Headers[ContentType] = contentType; 
     } 
     } 

     this._client.UploadDataAsync(new Uri(url), form.data); 
    } 

    /// <summary> 
    /// Gets the error message. Returns null if there is no error. 
    /// </summary> 
    /// <value> 
    /// The error message. 
    /// </value> 
    public string Error 
    { 
     get 
     { 
     return this._error; 
     } 
    } 

    /// <summary> 
    /// Gets a value indicating whether this request is done. 
    /// </summary> 
    /// <value> 
    /// <c>true</c> if this instance is done; otherwise, <c>false</c>. 
    /// </value> 
    public bool IsDone 
    { 
     get 
     { 
     return this._isDone; 
     } 
    } 

    /// <summary> 
    /// Gets the progress, 0 to 1. 
    /// </summary> 
    /// <value> 
    /// The progress. 
    /// </value> 
    public float Progress 
    { 
     get 
     { 
     return this._progress/100.0f; 
     } 
    } 

    /// <summary> 
    /// Gets the resulting text. 
    /// </summary> 
    /// <value> 
    /// The text. 
    /// </value> 
    public string Text 
    { 
     get 
     { 
     return this._text; 
     } 
    } 

    /// <summary> 
    /// Called when the download is complete. 
    /// </summary> 
    /// <param name="sender">The sender.</param> 
    /// <param name="e">The <see cref="DownloadStringCompletedEventArgs"/> instance containing the event data.</param> 
    private void WebClientDownloadCompleted(object sender, DownloadStringCompletedEventArgs e) 
    { 
     if (e.Error != null) 
     { 
     this._error = e.Error.ToString(); 
     } 
     else 
     { 
     this._text = e.Result; 
     } 

     this._isDone = true; 
    } 

    /// <summary> 
    /// Called when the progress changes. 
    /// </summary> 
    /// <param name="sender">The sender.</param> 
    /// <param name="e">The <see cref="DownloadProgressChangedEventArgs"/> instance containing the event data.</param> 
    private void WebClientProgressChanged(object sender, DownloadProgressChangedEventArgs e) 
    { 
     this._progress += e.ProgressPercentage; 
    } 

    /// <summary> 
    /// Called when the upload is complete. 
    /// </summary> 
    /// <param name="sender">The sender.</param> 
    /// <param name="e">The <see cref="UploadValuesCompletedEventArgs"/> instance containing the event data.</param> 
    private void WebClientUploadCompleted(object sender, UploadDataCompletedEventArgs e) 
    { 
     if (e.Error != null) 
     { 
     this._error = e.Error.ToString(); 
     } 
     else 
     { 
     this._text = Encoding.UTF8.GetString(e.Result); 
     } 

     this._isDone = true; 
    } 

    /// <summary> 
    /// Called when the upload progress changes. 
    /// </summary> 
    /// <param name="sender">The sender.</param> 
    /// <param name="e">The <see cref="UploadProgressChangedEventArgs"/> instance containing the event data.</param> 
    private void WebClientUploadProgressChanged(object sender, UploadProgressChangedEventArgs e) 
    { 
     this._progress += e.ProgressPercentage; 
    } 
} 
相关问题