gpt4 book ai didi

macos - 协同设计/打包后 OSX Mac 商店应用程序联网失败

转载 作者:行者123 更新时间:2023-12-03 17:41:06 26 4
gpt4 key购买 nike

我有一个内置在 Unity 中的应用程序,并设置要在 Mac App Store 上发布,它的网络任务在 OS X 构建中工作得很好,这不适用于应用程序商店,但一旦构建需要 App Store 验证/协同设计联网失败。该应用程序和构建过程不久前还有效,但现在失败了。

我在权利中包含了网络权限,并且在系统控制台中没有看到任何沙盒错误的痕迹。应用内购买网络调用成功,但如果我检查终端中其他任何内容的流量,则没有数据移入或移出。

因此,我想知道是否有人对可能导致此问题的原因有任何想法,或者我可以使用进一步的测试来找出问题所在。

最佳答案

我从来没有弄清楚 Unity 的 WWW 类出了什么问题,但我能够使用 System.Net.WebClient 类解决这个问题。我实现了一个简单的包装器,它具有与 Unity 的 WWW 类类似的接口(interface)。这是我使用的代码:

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;
}
}

关于macos - 协同设计/打包后 OSX Mac 商店应用程序联网失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36062526/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com