Appcenter分发在Xamarin.iOS中不起作用的应用程序内更新

时间:2019-05-31 23:19:10

标签: xamarin.ios visual-studio-app-center visual-studio-app-center-distribute

我正在尝试使用Visual Studio AppCenter分发内部iOS应用程序(使用Xamarin.iOS构建),但似乎无法获得应用程序更新。

当我(通过电子邮件链接)下载并安装该应用程序时,浏览器将永远不会打开以注册应用程序更新,并且当我向该组分发新版本时,该应用程序不提供更新。

我已按照https://docs.microsoft.com/en-us/appcenter/sdk/distribute/xamarin

上的说明进行操作

我添加了info.plist条目并启动了appcenter分发模块。 Analytics +崩溃报告运行正常,因此AppCenter ID很好。

任何帮助将不胜感激。

2 个答案:

答案 0 :(得分:0)

@lavanya关于它们为什么不起作用的原因可能有很多。如您在注释herehere中所见,

  1. 您的测试人员是否从默认的野生动物园浏览器下载了该应用程序?

  2. 是否在其设置中为Safari启用了cookie?

  3. 您的应用程序是否尚未在App Store中提供?

能否请您提供更多详细信息?因为如果您对上述任何一个问题回答“否”,您将无法在iOS上使用MS App Center的“应用内更新”

答案 1 :(得分:0)

如果要创建自己的VersionChecker,则在第一个视图控制器的ViewDidLoad的覆盖中,可以调用CheckVersion()函数

public override void ViewDidLoad()
{        
    base.ViewDidLoad();
    CheckVersion();
    OtherCode();
}

然后在CheckVersion函数中,您可以执行以下操作

        public async void CheckVersion()
        {
            var newVersionAsString = new VersionObject();
            string responseContent = string.Empty;

            using (HttpClient httpClient = new HttpClient())
            {
                try
                {
                    var versionCheckUri = "https://gist.githubusercontent.com/saamerm/af01aec0187d38a22fdd9b4378afc9c3/raw/680332a9a45eb015bc17fbf817fbac537348e3d4/Version.json"
                    using (HttpResponseMessage httpResponse = await httpClient.GetAsync(versionCheckUri))
                    {
                        if (httpResponse.StatusCode == System.Net.HttpStatusCode.OK)
                        {
                            responseContent = await httpResponse.Content.ReadAsStringAsync();
                            newVersionAsString = JsonConvert.DeserializeObject<VersionObject>(responseContent);
                        }
                    }
                }
                catch (Exception)
                {
                }
            }

            var currentVersion = new Version(NSBundle.MainBundle.InfoDictionary["CFBundleShortVersionString"].ToString());

            if (currentVersion != null && !string.IsNullOrWhiteSpace(newVersionAsString) && (new Version(newVersionAsString.latestVersion)) > currentVersion)
            {
                string AppleStoreAppUrl = "itms-apps://itunes.apple.com/us/app/pages/{YOURAPPURL}?mt=8";
                var alert = new AlertView { ViewController = this, Title = "Update Required", Message = "To continue using this mobile app, please install the latest version." };
                alert.AddAction("Update Now", ActionStyle.Cancel, (action) => { UIApplication.SharedApplication.OpenUrl(new NSUrl(AppleStoreAppUrl)); this.Dispose(); }).Show();
            }

我们从jsonutils.com获得的VersionObject

 public class VersionObject
    {
        public string latestVersion { get; set; }
    }

请在使用它之前对其进行测试,我可以看到一个可能无法正常工作的实例