首页 > 解决方案 > App Center 应用内更新未显示在 Xamarin Android 应用中

问题描述

我正在尝试为我的 Xamarin Android 应用程序中的应用程序内更新配置 AppCenter.Distribute。这是非常基本的设置代码,我在我的主启动器活动的 OnCreate 方法中(在 base.OnCreate 调用之后):

AppCenter.Start (Resources.GetString (Resource.String.appcenter_app_secret), typeof (Analytics), typeof (Crashes), typeof (Distribute));

我能够获得应用内更新以进行所谓的初始化。当我第一次安装并打开该应用程序时,它会显示一个浏览器窗口一秒钟,上面写着“应用程序内更新已启用!正在 1 内返回应用程序...”,然后它重定向回我的应用程序。不幸的是,当我修改版本名称和代码并分发新版本时,我没有在应用程序中看到提示我更新到新版本的对话框。

我什至尝试处理 Distribute.ReleaseAvailable 操作并显示自定义对话框,并且该操作也没有被调用:

Distribute.ReleaseAvailable = OnReleaseAvailable;// Called before AppCenter.Start

private bool OnReleaseAvailable(ReleaseDetails releaseDetails)
{
    // Show custom dialog.
    Droid.ApplicationContext.Activity.CustomDialogBuilder().Show(new NotificationArgs
    {
        Title = "New update available!",
        Message = "A new version of RPR Mobile, {0} ({1}) is available. Release notes: {2}"
            .WithFormat(releaseDetails.ShortVersion, releaseDetails.Version, releaseDetails.ReleaseNotes),
        PositiveButtonText = "Update",
        PositiveAction = () =>
        {
            // Notify SDK that user selected to update...
            Distribute.NotifyUpdateAction(UpdateAction.Update);
        },
        HideNegativeButton = releaseDetails.MandatoryUpdate,
        NegativeButtonText = "Postpone Update",
        NegativeAction = () =>
        {
            // Notify SDK that user selected to postpone (for 1 day)...
            // Note that this method call is ignored by the SDK if the update is mandatory.
            Distribute.NotifyUpdateAction(UpdateAction.Postpone);
        }
    });
    // Return true if you are using your own dialog, false otherwise.
    return true;
}

我想知道我错过了什么。一些可能相关或不相关的问题......

  1. AppCenter.Start 代码在 base.OnCreate 调用之前还是之后执行是否重要?
  2. 调用 AppCenter.Start 的活动是正在运行还是已完成是否重要?因为在我们的例子中,主启动器只是一个启动屏幕,几秒钟后就会关闭。
  3. App Center SDK 是否应该每隔几秒轮询一次以获取更新?还是仅在打开和关闭活动时检查?

标签: xamarinxamarin.androidvisual-studio-app-centervisual-studio-app-center-distribute

解决方案


事实证明,您必须关闭并重新启动您的应用程序才能检查新更新。文档可能会更清楚...


推荐阅读