我正在尝试配置AppCenter.Distribute以在我的Xamarin Android应用程序中进行应用程序内更新。这是非常基本的设置代码,我在主启动器活动的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;
}
我想知道我缺少什么。一些可能相关或可能不相关的问题...
答案 0 :(得分:0)
事实证明,您必须关闭并重新启动您的应用程序才能检查新更新。文档可能对此更加清晰...