Search code examples
xamarinxamarin.androidvisual-studio-app-centervisual-studio-app-center-distribute

App Center in-app updates not showing up in Xamarin Android app


I'm attempting to configure AppCenter.Distribute for in-app updates within my Xamarin Android app. Here is the very basic setup code, which I have in my main launcher activity's OnCreate method (AFTER the base.OnCreate call):

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

I was able to get the in-app updates to supposedly initialize. When I first install and open the app, it shows a browser window for one second that says "In-app updates enabled! Returning to app in 1...", then it redirects back to my app. Unfortunately, when I then bump the version name and code and distribute a new build, I don't get a dialog within the app prompting me to update to the new version.

I even tried handling the Distribute.ReleaseAvailable action and showing a custom dialog, and that action isn't invoked either:

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;
}

I'm wondering what I'm missing. Some questions that may or may not be relevant...

  1. Does it matter whether the AppCenter.Start code executes before or after the base.OnCreate call?
  2. Does it matter whether the activity that AppCenter.Start is called from is running or finished? Because in our case, the main launcher is just a splash screen that closes after a couple seconds.
  3. Is the App Center SDK supposed to poll every few seconds for an update? Or does it check only when opening and closing activities?

Solution

  • It turns out that you have to close and relaunch your app for it to check for new updates. The documentation could be more clear on this...