2

I am trying to distribute an internal iOS app (built using Xamarin.iOS) using Visual Studio AppCenter, but can't seem to get in-app updates to work.

when I download and install the app (through the email link) the browser never opens to register for in-app updates, and when I distribute a new release to that group, the app does not offer an update.

I've followed the instructions here.

I've added the info.plist entries and started the appcenter distribute module. Analytics + Crash reporting are working OK so the AppCenter ID is fine.

Any help would be appreciated.

Saamer
  • 4,687
  • 1
  • 13
  • 55
lavanya
  • 45
  • 4

2 Answers2

0

@lavanya there could be a lot of different reasons as to why they are not working. As you can see in the Notes here and here,

  1. Did your testers download the app from the default safari browser?

  2. Are cookies enabled for Safari in their settings?

  3. Is your app not available in the App Store yet?

Could you please provide more details? Because if you answered No to any of those questions, you won't be able to use MS App Center's In App Updates on iOS

Saamer
  • 4,687
  • 1
  • 13
  • 55
  • Thank you for the reply. 1. Did your testers download the app from the default safari browser? Yes, we downloaded the app from the email we get once its distributed from the appcenter 2. Are cookies enabled for Safari in their settings? Yes 3. Is your app not available in the App Store yet? Yes. – lavanya Jun 03 '19 at 21:17
  • So first I coded the app as per the doc and uploaded version (1.0) and distributed it. Installed it in iPhone from the Email. So to test in app update, I have uploaded another version (1.1) . So now when i open 1.0 version app its not prompting any update version dialog. Not sure what's going on. Please help me out. Thank you inadvance. – lavanya Jun 03 '19 at 21:27
  • @lavanya Im so sorry for what you're facing. Why don't you just create a simple Gist JSON file containing a Version so the app can check that every time you load the app – Saamer Jun 03 '19 at 22:14
  • Yeah thats a good idea but I am not sure how our app can compare the versions. Any idea on like how to access the property list file of the latest version in the appcenter?. That way I can get the version info of the latest version and then can compare it with current app bundle version – lavanya Jun 03 '19 at 22:22
  • The code in AppDelegate FinishedLaunching Distribute.SetEnabledAsync(true); Distribute.DontCheckForUpdatesInDebug(); Distribute.ReleaseAvailable = OnReleaseAvailable; // Custom dialog bool enabled = Distribute.IsEnabledAsync().Result; AppCenter.LogLevel = LogLevel.Verbose; AppCenter.Start("app secret", typeof(Analytics), typeof(Crashes), typeof(Distribute)); Let me know if I have done anything wrong in the coding – lavanya Jun 03 '19 at 22:27
  • You create a rest call for the raw version of a gist like this https://gist.githubusercontent.com/saamerm/af01aec0187d38a22fdd9b4378afc9c3/raw/680332a9a45eb015bc17fbf817fbac537348e3d4/Version.json . You can use https://jsonutils.com to create the Model class. Doing a JSON serialize, you will get current version. Place a check so that every time the user gets on the Home page, if they don't have the current version of the app, it Displays the Alert. And when they tap on it, you can direct them to the Website where they can download the right version – Saamer Jun 03 '19 at 22:43
  • Check the other Answer I posted – Saamer Jun 03 '19 at 22:58
0

If you want to create your own VersionChecker, in the override of the ViewDidLoad of the first view controller, you can call the CheckVersion() function

public override void ViewDidLoad()
{        
    base.ViewDidLoad();
    CheckVersion();
    OtherCode();
}

And then in the CheckVersion function you could do something like this

        public async void CheckVersion()
        {
            var newVersionAsString = new VersionObject();
            string responseContent = string.Empty;

            using (HttpClient httpClient = new HttpClient())
            {
                try
                {
                    var versionCheckUri = "https://gist.githubusercontent.com/saamerm/af01aec0187d38a22fdd9b4378afc9c3/raw/680332a9a45eb015bc17fbf817fbac537348e3d4/Version.json"
                    using (HttpResponseMessage httpResponse = await httpClient.GetAsync(versionCheckUri))
                    {
                        if (httpResponse.StatusCode == System.Net.HttpStatusCode.OK)
                        {
                            responseContent = await httpResponse.Content.ReadAsStringAsync();
                            newVersionAsString = JsonConvert.DeserializeObject<VersionObject>(responseContent);
                        }
                    }
                }
                catch (Exception)
                {
                }
            }

            var currentVersion = new Version(NSBundle.MainBundle.InfoDictionary["CFBundleShortVersionString"].ToString());

            if (currentVersion != null && !string.IsNullOrWhiteSpace(newVersionAsString) && (new Version(newVersionAsString.latestVersion)) > currentVersion)
            {
                string AppleStoreAppUrl = "itms-apps://itunes.apple.com/us/app/pages/{YOURAPPURL}?mt=8";
                var alert = new AlertView { ViewController = this, Title = "Update Required", Message = "To continue using this mobile app, please install the latest version." };
                alert.AddAction("Update Now", ActionStyle.Cancel, (action) => { UIApplication.SharedApplication.OpenUrl(new NSUrl(AppleStoreAppUrl)); this.Dispose(); }).Show();
            }

where VersionObject we got from jsonutils.com

 public class VersionObject
    {
        public string latestVersion { get; set; }
    }

Please test this before using it, I can see an instance where it may not work

Saamer
  • 4,687
  • 1
  • 13
  • 55
  • Thanks @saamer. I will test it before using it. Thanks for the help. – lavanya Jun 03 '19 at 23:58
  • Hi @saamer, I have tried the above code and tested it, I am able to get the latest version but when I want to download it the url needs be of appcenter not the App Store (since the app is not in App Store). Any idea about the app url in appcenter.? – lavanya Jun 05 '19 at 01:29
  • Hmm yeah what's your appcenter URL when you access it from the iPhone? – Saamer Jun 05 '19 at 03:43
  • Hi Saamer, The app center url from the phone shows as https://install.appcenter.ms/users/lavanya.naredla/apps/Sample/releases/5?source=email. Not sure whether it works or not :) – lavanya Jun 05 '19 at 20:20
  • What about the App Center URL of the app? Maybe you haven't placed the apps inside an organization – Saamer Jun 05 '19 at 20:27
  • One question @saamer, Right now I have my apps in hockey app, and I am trying to transit to app center, Can I use url "https://rink.hockeyapp.net/api/2/apps/appid" even after hockey app retire? Yeah you are right, I did not placed my apps in organization. – lavanya Jun 05 '19 at 20:47
  • You ll be able to for a little bit, but they ll get rid of it completely. Place your apps in an organization and then access the app from there. That way testers who visit that page, will be directed to download the iOS app in a few clicks – Saamer Jun 05 '19 at 21:34
  • @lavanya any success on this? – Saamer Jun 10 '19 at 17:08
  • Hi @saamer, when I gave the download url from iPhone like https://install.appcenter.ms/org/yourorganizationname/apps/appname/distribution_groups/distributiongroupname, it says cannot connect to install.appcenter.ms. – lavanya Jun 10 '19 at 22:07
  • The ur is not working when i try to install it from Xamarin.ios app only. When I try to open the url from safari browser it downloads the app – lavanya Jun 10 '19 at 22:24
  • Yes, you have to tell the app to open the url in the browser – Saamer Jun 11 '19 at 15:58
  • The entire download url I gave looks like itms-services://?action=download-manifest&url=https://install.appcenter.ms/org/yourorganizationname/apps/appname/distribution_groups/distributiongroupname. It should work right? – lavanya Jun 11 '19 at 16:34
  • itms-services:// opens the App Store on your phone, and since your app on AppCenter, is not going to be visible/available through there, you just have to use string AppCenterUrl = "install.appcenter.ms/org/yourorganizationname/apps/appname/…" instead and remove the whole itms-services:// stuff – Saamer Jun 11 '19 at 16:45
  • What if I don't want to open the appcenter page and directly wants to install the version into phone. My client will not be liking to visit the appcenter from our app and install it. Right now using HockeyApp I gave the url like itms-services://?action=download-manifest&url=https://rink.hockeyapp.net/api/2/apps/appid and it directly starts installing the app into the phone without me taking to the HockeyApp version page – lavanya Jun 11 '19 at 16:55
  • Hmm, you cant do that with the MS App Center. But ignoring the certification issues that you might face, for that you will have to manually upload your builds to a website like dropbox or google drive and just put in the public link to the build. Perhaps you could extend your Github Gist to have the URL to the build as well and then just open that link instead – Saamer Jun 11 '19 at 16:59
  • Hmm yeah right. Thank you for all your support and responses.Really appreciate it. :) – lavanya Jun 11 '19 at 17:02