Building a non-trivial cross platform app using Xamarin

Over the past year or two we’ve been using Xamarin to build a moderately complex mobile application. On Key Work Manager is a mobile work order management solution that enables your field service staff to manage their work assignments and forms part of the On Key Enterprise Asset Management system.

To illustrate why I say this is as a moderately complex app, here are some of the features:

  • Location tracking
  • Maps integration
  • Electronic PDF form filling and generation
  • Electronic signatures to support signing off job cards
  • Barcode scanning of assets
  • Document attachments including photos, in-app voice recordings etc.
  • Local notifications
  • Background services to synchronise data whilst the app is not running
  • Full offline support - i.e. app functionality works in offline environments and only requires peridic connectivity to synchronise changes to server

Based on local market demands, we targeted Android first and published the Android version of the application mid 2016. Last week we published the iOS version of the application.

I’ve had one or two enquiries from people on what tools/libaries/frameworks we used to build the app. This post will give a rundown of what we use.

Frameworks

One of the principles we followed from the word go, was to try and maximize the re-use of shared logic across the different platforms. The team had experience using the MVVM pattern so we decided on using a framework that would supprt the MVVM pattern. Xamarin Forms was still in its infancy at that stage so we decided to look for a framework that would allow us to build directly on top of the native platform thus giving us full access to the native platform performance, native iOS and Android controls, native navigation mechanisms etc.

We ended up using a blend of the excellent MvvmCross and our own small homegrown framework that covered aspects like navigation and bootstrapping a bit differently as to how MvvmCross prescribes. This is a big shout out to the community members behind MvvmCross like Tomasz and Martijn00. The fact that we were able to replace aspects of MvvmCross is also a compliment to the overall design of the framework. MvvmCross v5 is shaping up to be an awesome release as well.

Using the MVVM pattern we are able to share up to 70-75% of the code base between the different platforms in a PCL library.

Testing

We have an extensive set of NUnit unit tests covering the shared logic contained in our PCL library that we execute on our TeamCity CI server. We are also in the early phases of using Xamarin.UITest to do automated UI testing.

Plugins/3rd Party Components

We use the following plugins/components to support the app features:

NuGet Packages/Libraries

Besides the frameworks/plugins/controls, we use the following NuGet packages:

Testing/Analytics/Crash Reporting

For ALPHA, BETA testing, crash reporting and application insights we use HockeyApp

I think that’s about it! Since we started using Xamarin, the whole ecosystem around Xamarin including the plugins, components have evolved quite nicely. This allows us to focus on building the features of our app instead of having to re-invent the wheel. Overall we are quite happy with how our code base has turned out and we are looking forward to building more apps using Xamarin.

Messaging Plugin for Xamarin 4 released

I’ve just published the final build of the next major version of the Messaging Plugin to NuGet. I’ve added no new features since the last beta build.

Here is the complete list of changes for v4 of the plugin:

  • Add support for sending SMS to multiple recipients
  • Android+UWP: Add support for sending SMS without user interaction via the ISmsTask.CanSendSmsInBackground and ISmsTask.SendSmsInBackground
  • Android: Add support for using FileProvider to add attachments using content Uri’s on Android Nougat and later
  • Android: Add new Settings class to configure Android specific behavior when sending emails/making phone calls (see next bullets). Access from Android project only using CrossMessaging.Current.Settings() extension method.
    • Add new EmailSettings.UseStrictMode flag (default value false) to filter list of apps to only email apps and not other text messaging or social apps. Unfortunately adding attachments when using StrictMode does not seem to work, and is therefore currently not supported.
    • Add new PhoneSettings.AutoDial flag (default value false) to automatically phone the number instead of only showing the phone dialer with the number populated. Please note using this settings requires the android.permission.CALL_PHONE added to the manifest file.
  • Breaking Change: Remove iOS Classic support
  • Breaking Change: Remove Windows Phone 8.0 and 8.1 support
  • Breaking Change: Reworked EmailMessageBuilder.WithAttachment platform API to provide consistent API

Full details of how to use the plugin can be found here. You can also find samples illustrating the use of the different features in the GitHub repo.

Messaging Plugin for Xamarin 4 Beta

I’ve just published another beta build of the next major version of the Messaging Plugin to NuGet.

New feature added in this build:

  • Android+UWP: Add support for sending SMS without user interaction via the ISmsTask.CanSendSmsInBackground and ISmsTask.SendSmsInBackground. Thanks to soroshsabz for the initial contribution.

I’m hoping that this is the final build before publishing v4 of the plugin. Take it for a spin and let me know if you run into any issues

Messaging Plugin for Xamarin 4 Alpha2

I’ve just published another alpha build of the next major version of the Messaging Plugin to NuGet.

New features/changes in this build are Android related and include:

  • Android: Add new CrossMessaging.Current.Settings().Email.UseStrictMode flag (default value false) to filter list of apps to only email apps and not other text messaging or social apps. This replaces the EmailMessageBuilder.UseStrictMode added in the first alpha.
  • Android: Add new CrossMessaging.Current.Settings().Phone.AutoDial flag (default value false) to automatically phone the number instead of only showing the phone dialer with the number populated. Please note using this settings requires the android.permission.CALL_PHONE added to the manifest file.

Messaging Plugin for Xamarin 4

I’ve just published an early alpha build of the next major version of the Messaging Plugin to NuGet. Visit the Change Log to see what’s changed. Here are some highlights:

  • Add support for sending SMS to multiple recipients
  • Android: Add support for using FileProvider to add attachments using content Uri’s on Android Nougat and later
  • Android: Add new EmailMessageBuilder.UseStrictMode to filter list of apps to only email apps and not other text messaging or social apps. (Unfortunately adding attachments when using StrictMode does not seem to work, and is therefore currently not supported.)
  • Breaking Change: Remove iOS Classic support
  • Breaking Change: Remove Windows Phone 8.0 and 8.1 support
  • Breaking Change: Reworked EmailMessageBuilder.WithAttachment platform API to provide consistent API for adding attachments

Due to the breaking changes introduced, the version of the plugin has been bumped to v4.0.0. Take it for a spin and let me know if you run into any issues