Exposing Siri Shortcuts actions from your Xamarin iOS application

February 3, 2021

In this post I will give you the resources for you to go and implement Siri Shortcuts actions in your Xamarin application.

Note before you get started the following guide is something I would class as advanced so if you are new to Xamarin then I would bookmark this post and come back once you have played around a little more. You will also need to be running macOS as this requires you to install Xcode and create either an objective c or swift library.

Siri Shortcuts

First, what are Siri Shortcuts? In 2018 Apple introduced Siri Shortcuts which allowed applications to expose functions to extend Siri, either through using your voice or via the Shortcuts application. The example that Apple use to demo this was the ability to be able to extend Siri to allow you to Order Soup with Siri from the application they had created named Soup Chef. You can check out the following video to take a look at how to get started wwdc2018/211.

Then in 2019, these were enhanced to allow users to interact with these functions with parameters. These parameters can be anything the example that Apple gave was taking the Soup Chef application and the Order actions that they created originally to allow you to pass in the type of Soup to order and which store to order it from. You can check out the following video to learn how to add parameters to your intents wwdc2019/213

They have further extended these in 2020 to allow you to run the actions in the context of your application but this is something you should take a look at why you might want to do this once you have the basics of implementing the functions mentioned above. The reason that is the guide that Microsoft provides that is talked about below hasn't been updated to incorporate this and if you are adding this to a Xamarin Forms application you need to make further changes to how your application functions that is not supported and might have unintended side effects.

Note If reading documentation is more your thing you can read about the SiriKit framework here SiriKit documentation

Guide to implementing actions in Xamarin

That is enough discussing what Siri Shortcuts are lets get in to adding them to your application. I originally planned on creating a step-by-step guide but Microsoft have provided a fairly in-depth guide for you to implement this. They have also taken the Soup Chef example application mention above and created a Xamarin version which you can also find a link in the guide available here. I will say pay particular attention to the section "Using a custom intent shortcut to perform a task" as the guide talks about implementing many parts of the SiriKit framework.

Copyright © 2020-2021 Shaun Hevey All Rights Reserved, except for the parts enumerated below:
  • The source code examples shown are covered by the MIT License unless otherwise stated.