xamarin - 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;
}
我想知道我错过了什么。一些可能相关或不相关的问题......
- AppCenter.Start 代码在 base.OnCreate 调用之前还是之后执行是否重要?
- 调用 AppCenter.Start 的活动是正在运行还是已完成是否重要?因为在我们的例子中,主启动器只是一个启动屏幕,几秒钟后就会关闭。
- App Center SDK 是否应该每隔几秒轮询一次以获取更新?还是仅在打开和关闭活动时检查?
解决方案
事实证明,您必须关闭并重新启动您的应用程序才能检查新更新。文档可能会更清楚...
推荐阅读
- css - Material UI:如何在用户与滑块交互时更改滑块拇指的可见性,即更改滑块值?
- python - 在日期时间值列表中,如何获取具有特定日期(不是 datw 时间)的元素
- javascript - 如何在 OOP 中使用 fetch?
- php - woocommerce 帐户页面中的隐藏元素(行)
- java - 触发 @OneToMany 延迟获取
- docker - “drone exec”不支持管道类型(exec)
- reactjs - 在显示 react-apexchart 之前显示加载程序
- python-3.x - 使用 Scapy 发送嗅探到的 ESP 数据包
- php - 为什么没有在 php 中使用存储的访问令牌和刷新令牌创建谷歌日历事件
- filemaker - FileMaker 为记录的所有/部分字段自动生成按钮和字段?