question

GaneshGebhard-8778 avatar image
0 Votes"
GaneshGebhard-8778 asked JarvanZhang-MSFT commented

Xamarin Forms - Cannot get In-app Updates from App Center to work

Hey!

I have an app in Xamarin Forms (Android & iOS), which is distributed in App Center. I'm trying to enable the option to perform an in-app update when a new build has been completed, but I cannot get this to work. I'm using the tutorial on Microsoft Docs: https://docs.microsoft.com/en-us/appcenter/sdk/distribute/xamarin#remove-in-app-updates-for-google-play-builds

What I tried to build is the option to manually check for updates by pressing on a button. This button is just doing..nothing when I press it, but maybe someone here had that problem before as well.

The code that I have are given below. This example is for Android first (since I'm testing on a phyical Android device), but it should work for iOS as well.

Packages
So first I have installed the App Center Distribution package. Not the latest version (4.2.0), since the build is App Center fails then because it cannot handle version 4.1.0+ (I spoke to someone from App Center to confirm this).
96745-image.png

App.cs
Then in App.cs, I have the following code:

96685-image.png

Where OnReleaseAvailable is the following (literally from the docs):

96679-image.png

MainActivity (Android)
Then in the Android MainActivity, I added the option to enable this for debug builds:

96727-image.png

Check for Update option
Then I have a button on a ContentPage to check for updates:

96770-image.png

I believe I have everything then for this option, but when I press the button nothing happens, update found or no update found.

Does someone know what I'm missing here?

Best,
Ganesh

dotnet-xamarin
image.png (24.8 KiB)
image.png (35.3 KiB)
image.png (57.1 KiB)
image.png (12.2 KiB)
image.png (4.1 KiB)
· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi, GaneshGebhard. Did you update the versionCode or versionName for the Android release. Android devices won't be prompted for an update if there's no change in versionCode or versionName.

0 Votes 0 ·

Aha, that makes a lot of sense. I thought the version number, which is generated based on the build number, was the version code, but now that you mention it this is false. How can I update the version code or version name with each release? Do I have to do this manually in Android Manifest? Or is there some kind of super efficient way? And how about iOS?

The reason I ask is because I make changes to the app, create commits and send these to DevOps. Once in a while, I'll update the app and I want the users to be able to update this from the app itself. Now it seems that I have to update the versionCode manually, commit this change and then build the solution in App Center. There must be a more efficient way to do this I suppose.

0 Votes 0 ·

How can I update the version code or version name with each release?

We need to change the value manually in each release. In iOS, set the value of the CFBundleVersion key.
https://docs.microsoft.com/en-us/xamarin/android/deploy-test/release-prep/?tabs=windows#version-the-application

Please try to update the version number when publish a new release to the AppCenter to check if the update will work.
0 Votes 0 ·
Show more comments

0 Answers