Appcenter-sdk-dotnet: Add Distribute API to check for updates

Created on 5 Oct 2018  ·  23Comments  ·  Source: microsoft/appcenter-sdk-dotnet

Description

Following the guide on site I set up in-app updates for a Xamarin.Forms (only Android for now) app.
I register the callback just before the AppCenter.Start inside App.xaml.cs OnStart() method.
I precisly need to know when the callback is supposed to be called: every time the app starts? every time the activity resume? ... The documentation is not clear at all on this point :-)
This is because the app is designed to work in single application mode inside a kiosk and never reboots, nor is the activity changed. In HockeyApp you could decide when to check for new updates, here how I can do it?
I know I'm forced to interact with the user to be able to update the app but I want this is the only case.
In this scenario it seems also that MandatoryUpdate doesn't work because it is always false, also when I distributed a mandatory build (in our case all distributed builds will be mandatory).
Finally...please provide a way to te test in-app updates in debug otherwise it is not comfortable at all...

Thank you! :-)

Details

  1. What is your app platform (Xamarin.Android or Xamarin.iOS or UWP)?
    Xamarin.Forms with Android only target
  2. If using Xamarin.Forms or if using portable/shared code to call our SDK APIs, are you using shared project, PCL code or .NET standard code for the application? Which .NET standard version or which PCL profile?
    .NET standard 2.0.
  3. Which SDK version are you using?
    1.9.0
  4. Which OS version did you experience the issue on?
    the device has Android 7.1.0, project compiled with 8.1 Api 27 SDK
  5. What device version did you see this error on? Were you using an emulator or a physical device?
    Physical device Lenovo Tab 4 10
feature request

All 23 comments

As of now, updates are checked when the Distribute service starts. However, while we don't have an API to check for available updates, you can work around this by disabling and then re-enabling the Distribute service.

            await Distribute.SetEnabledAsync(false);
            await Distribute.SetEnabledAsync(true);

Can you please clarify the point about the mandatory updates? Do you mean that when you try to distribute a mandatory update it isn't really mandatory?

Thank you @achocron for now I try with the workaround. For the future it will be nice to don’t check at all. Something like: call the callback when new release is available for the distribution group and the app (the device) is in that group. I think you have an “event” when the user from the portal (or from the rest api) creates a new release.

For mandatory updates yes, exactly what you said, it seems that they are always not mandatory.

Another point is that the automatic update procedure seems very slow: it takes more than a minute from when the user chooses to update (by sending “UpdateAction.Update” notification to the AppCenter) and when the popup to start up the update procedure is shown. In hockeyapp was practically immediate and at the end the application restarted automatically...here no, another prompt to the user.

The download of the new version happens when the “UpdateAction.Update” is notified to the SDK. Then it depends on the network, weight of the application...

@andrekiba what do you exactly mean by the mandatory updates are not mandatory? In the release details passed to the onReleaseAvailable do you see the MandatoryUpdate property being true?

Another time about mandatory updates: no. @cipolet I already said that the property MandatoryUpdate inside the ReleaseDetails object is always false...also when I set the release as mandatory from the app center portal. Is it clear? :-)
Is it something related to the type of distribution group? In my case is public.
Maybe I have to open a specific issue about this point?

For the update behavior: I understand that the download starts after UpdateAction.Update but is it possible to have the same behavior that I have in Hockeyapp?
For example a dialog that shows a progress about the download and then install the app.
Otherwise the user doesn't understand what is happening because there is no feedback.
Or at least provide an event (when the download is complete and the app is ready to be installed) that I can use to dismiss a custom dialog that I started when user had selected UpdateAction.Update.

could you please check and give me a feedback related to mandatory updates??

@andrekiba sorry for the late response. About the first point (mandatory update bug) you should create an AppCenter support request (blue button bottom right of the AC portal). It might not be just an SDK issue.
Let me double check about the no user feedback on update that seems odd.

I did some testing on our Xamarin Form test application to verify the behavior, as you said the SDK is taking care of the download after the UpdateAction.Update but it does trigger a system notification in the notification tray that shows the progress of the download. When the download is done then Android would popup the update dialog (without me doing anything) to update the application.

So you are saying that you don't see the system notification that shows the progress of the download?

Can you please share a code snippet of your customization so we can try to reproduce the issue. Also when you disable your customization are you seeing the progress of the download?

Thanks.

Thank you for your reply @clpolet.
Yes the behavior that you have described it really happens (I didn't noticed this before) but I cannot understand what are the benefits compared to the old way what we have in Hockeyapp (progress dialog in app). Maybe in my application I don't want to use notifications, maybe the application is in single task mode (dedicated device) where notifications are disabled by default.
Is there a way to understand when the downlaod is done from within the app?
For the point related to mandatory updates I try to raise an AppCenter support request.

@andrekiba I don't think it's doable from what we expose today. Let me tag this as a feature flag. The tag is right already.

Today the mandatory updates download is shown as a modal progress dialog to prevent the user from using the app until the update is installed.

If the update is optional (default) the progress is not getting in the way, since we use the system download manager of Android the notification is actually managed by the system and you can still use the app during download.

Hockey App had issues with storage permissions and cleaning the files, that was fixed by switching to the system download manager.

A work around is to always use mandatory updates if you want the progress dialog in application every time.

Looks like you already do that and we just need to investigate why you receive updates as optional while you specified mandatory on the portal.

thank you very much for your explanation @guperrot. In this case the behavior is perfect and yes we need to understand why the release is not mandatory. I can only say that I set the mandatory flag on the portal but when the callback is called the release is always not mandatory :-(

I apologize for the inconvenience but can you please get in touch through Intercom/Support (blue button on the portal) so we can share more info in private and look at this end to end from both an SDK and a backend perspective? Please mention this GH issue and that you've been talking to the SDK crew.
Thanks in advance!

I tested on one of our testing app and the mandatory feature still works as I explained.
To be sure, please call AppCenter.LogLevel = LogLevel.Verbose before AppCenter.Start then in logcat logs you should see the following logs when the check is made:

2018-10-16 12:01:38.009 8459-8515/? V/AppCenterDistribute: Calling https://api.appcenter.ms/v0.1/sdk/apps/****************************ff29237c/releases/latest?release_hash=9c6119a9a424bab237aec6c2b6efde311ad37db800869df00849f5bd3449cc1e...
2018-10-16 12:01:38.009 8459-8515/? V/AppCenterDistribute: Headers: {x-api-token=********************************aa2211b7}

.... asynchronous, more logs can be interleaved ....

2018-10-16 12:01:38.829 8459-8515/? V/AppCenter: HTTP response status=200 payload={"app_name":"xamarin-demo-android","app_display_name":"Xamarin Demo Android","app_os":"Android","app_icon_url":"https://dl0tgz6ee3upo.cloudfront.net/production/apps/icons/000/441/100/original/4a9e7f370e8ca05827ecbdb644a2d42c.png","release_notes_url":"https://install.appcenter.ms/orgs/appcenter/apps/xamarin-demo-android?skip_registration=true","id":132,"version":"209","short_version":"1.9.0","size":22759888,"min_os":"4.0.3","android_min_api_level":"15","device_family":null,"bundle_identifier":"com.microsoft.appcenter.xamarin.forms.demo","fingerprint":"6c5dc9931245b45693b038c90a28ed23","uploaded_at":"2018-08-30T01:54:08.043Z","download_url":"https://rink.hockeyapp.net/api/2/apps/987b59414fac4968933e98a7ff29237c/app_versions/132?format=apk&avtoken=40c3f3106284a31dff887f1e108fbc224f127e39&mctoken=5d9c8b9f4e766e0aabadca648fc0d0401b75d2a6","install_url":"https://rink.hockeyapp.net/api/2/apps/987b59414fac4968933e98a7ff29237c/app_versions/132?format=apk&avtoken=40c3f3106284a31dff887f1e108fbc224f127e39&mctoken=5d9c8b9f4e766e0aabadca648fc0d0401b75d2a6","mandatory_update":true,"is_latest":true,"release_notes":"Merge pull request #739 from Microsoft/release/changelog_v1.9.0\n\nAdd 1.9.0 to changelog test","package_hashes":["bc9d8a79d42a7179a59d63c3b13f983ed3af69cfddc915f80b8a9b17048b2ff5"],"destination_type":"group","status":"available","distribution_group_id":"03f60f4e-5873-4062-b956-4761f4affd15","distribution_groups":[{"id":"03f60f4e-5873-4062-b956-4761f4affd15","name":"build","origin":"appcenter","display_name":"build","is_public":true}]}
2018-10-16 12:01:38.830 8459-8459/? D/AppCenterDistribute: Check if latest release is more recent.
2018-10-16 12:01:38.830 8459-8459/? D/AppCenterDistribute: Latest release more recent=true
2018-10-16 12:01:38.830 8459-8459/? D/AppCenterDistribute: Release is mandatory, ignoring any postpone action.
2018-10-16 12:01:38.830 8459-8459/? D/AppCenterDistribute: Latest release is more recent.
2018-10-16 12:01:38.830 8459-8459/? D/AppCenterDistribute: Calling listener.onReleaseAvailable.

Here the http response has a JSON field for "mandatory_update" : true.

sorry @guperrot In which way I can see this log? updates are disabled in debug mode...and the log works only in debug mode... what I missed?

Logs can be visible on a release if you call AppCenter.LogLevel = LogLevel.Verbose before AppCenter.start.

Then you use the Device Monitor in Tools (for VS for Mac, the windows menu might be slightly different) to look at the device logs and filter by AppCenter regular expression in log cat.

You should use a separate distribution group on app center for the build containing logs as this log enabling statement should not end up in your main production flow.

Can you also confirm that you created a support ticket on http://appcenter.ms feedback button so that the server team can help on this?

do you mean the chat? I tried two times without any response. Where is the feedback button?

@guperrot using your suggestion I can clearly see the logcat and, as supposed, the release is not mandatory: inside the json I can see
"mandatory_update" : false
and inside the custom log with my AmbrogioLog tag:
10-23 17:23:49.465 | AmbrogioLog | OnReleaseAvailable id=25 version=35 mandatory=False

Hi, thanks for the confirmation that it is not a SDK issue as we receive the wrong payload. Let's use the intercom ticket (that's the chat indeed but there is some delay) for this issue now that it's confirmed to be server side.

The API to check for updates is now available in version 3.1.0.

Was this page helpful?
0 / 5 - 0 ratings