2016-03-17 41 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; 
    } 
} 
相關問題