我正在阅读Microsoft的本文档/文章,内容涉及如何通过应用程序中心分发移动应用程序。问题是我真的不明白如何实现这一点。我在应用程序中心(Android)上有一个应用程序,我想实施强制更新,以便消除以前版本的错误。我尝试分发启用了强制更新的应用程序,但该应用程序无法正常工作。我该如何解决?
这就是我在 App.xaml.cs(XAMARIN FORMS PROJECT)中添加此代码的原因:
protected override void OnStart ()
{
AppCenter.Start("android={Secret Code};", typeof(Analytics), typeof(Crashes), typeof(Distribute));
Analytics.SetEnabledAsync(true);
Distribute.SetEnabledAsync(true);
Distribute.ReleaseAvailable = OnReleaseAvailable;
}
bool OnReleaseAvailable(ReleaseDetails releaseDetails)
{
string versionName = releaseDetails.ShortVersion;
string versionCodeOrBuildNumber = releaseDetails.Version;
string releaseNotes = releaseDetails.ReleaseNotes;
Uri releaseNotesUrl = releaseDetails.ReleaseNotesUrl;
var title = "Version " + versionName + " available!";
Task answer;
if (releaseDetails.MandatoryUpdate)
{
answer = Current.MainPage.DisplayAlert(title, releaseNotes, "Download and Install");
}
else
{
answer = Current.MainPage.DisplayAlert(title, releaseNotes, "Download and Install", "Ask Later");
}
answer.ContinueWith((task) =>
{
if (releaseDetails.MandatoryUpdate || (task as Task<bool>).Result)
{
Distribute.NotifyUpdateAction(UpdateAction.Update);
}
else
{
Distribute.NotifyUpdateAction(UpdateAction.Postpone);
}
});
return true;
}
这是我在 MainActivity.cs(ANDROID PROJECT)中添加的内容:
AppCenter.Start("{Secret Code}", typeof(Analytics), typeof(Crashes), typeof(Distribute));
答案 0 :(得分:1)
查看有关Xamarin表单的此App Center文档here-
You can customize the default update dialog's appearance by implementing the ReleaseAvailable callback. You need to register the callback before calling AppCenter.Start
您似乎需要交换当前订单,才能正常运行应用内更新。
答案 1 :(得分:0)