<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Chris Winstanley on Medium]]></title>
        <description><![CDATA[Stories by Chris Winstanley on Medium]]></description>
        <link>https://medium.com/@CWinstanley90?source=rss-5f28f7c27f1a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*PPRNDqfC9BM3zAcSf0Ra5g.jpeg</url>
            <title>Stories by Chris Winstanley on Medium</title>
            <link>https://medium.com/@CWinstanley90?source=rss-5f28f7c27f1a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 08 Sep 2026 00:57:45 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@CWinstanley90/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com" rel="hub"/>
        <item>
            <title><![CDATA[Hey Siri, when is my next tram?]]></title>
            <link>https://medium.com/@CWinstanley90/hey-siri-when-is-my-next-tram-7d9eb87fd304?source=rss-5f28f7c27f1a------2</link>
            <guid isPermaLink="false">https://medium.com/p/7d9eb87fd304</guid>
            <category><![CDATA[indiedev]]></category>
            <category><![CDATA[siri]]></category>
            <category><![CDATA[sirikit]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[app-development]]></category>
            <dc:creator><![CDATA[Chris Winstanley]]></dc:creator>
            <pubDate>Mon, 02 Jul 2018 16:21:58 GMT</pubDate>
            <atom:updated>2018-07-02T20:59:58.107Z</atom:updated>
            <content:encoded><![CDATA[<p>It’s been two weeks since WWDC and a lot of us have been trying out the new APIs for iOS 12. The most interesting for me by far was <strong>Siri Shortcuts</strong>. Shortcuts let you expose the main actions of your apps to Siri, using the new Siri Intents API. In this article, I’ll be showing you how I implemented it for my app Tram Times.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1gMpAIzKH23y_ACl4mEhow.png" /><figcaption>Hey Siri, Home time…</figcaption></figure><p>Over Christmas, I built an iOS and WatchOS app to track the tram times in Manchester. <a href="https://itunes.apple.com/us/app/tram-times/id1338236845?mt=8">Tram Times</a> seemed like the perfect candidate to try out the new api. Tram Times lets you add your favourite stations to your phone and watch, and requests the latest times from the Manchester public trams api when you need them. It is a simple app, but I really concentrated on a user being able to get the information they needed quickly. I achieved this by providing a simple interface in the app, Today Extensions and app shortcuts for a quick look. The ability to ask Siri for the next tram seemed like a no-brainer.</p><p>What seems more intriguing, is the off-product discovery available through <strong>Siri Suggestions</strong>. Using the new Intents api you can donate an <strong>Intent</strong> from your app every time the user performs an action you want Siri to know about. Siri will use the time/day, location and modality (walking, sitting, running) to suggest this action to you again at the most appropriate time. For Tram Times, Siri would use what it’s learnt about your usage to suggest you view the times in the morning when you catch it to work, or when you reach the location of your tram station when going home.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5Cf_jN_oYdh0NGP0YrWzjw.png" /></figure><h3>Designing Intents</h3><p>To start donating Intents you need to add a new file called an <em>intent definition file</em> to your project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6FFLHDUj0jqqPOCGKs4IJg.png" /><figcaption>Right click on your group/project -&gt; New File -&gt; SiriKit Intent Definition File -&gt; Next</figcaption></figure><p>Once added you can start creating your Intent. You want to select a <strong>category</strong> for your Intent such as View, Download or Order. Different categories can present different UI when the shortcut is activated for instance View will show just the shortcut whereas download will show the progress of your download. I have selected the <strong>Information</strong> category View as I want the user to be able to view the latest tram times with this intent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x_8-hkGizy0IXkjso2so7Q.png" /><figcaption>Intent Definition File</figcaption></figure><p>Enter the <strong>title</strong> for your intent and a description. You can decide here whether you want the user to <strong>confirm</strong> the intent (useful for orders). Define <strong>parameters </strong>that you want to use in your intent when you handle it. Here I have chosen my custom model type of Station. This is the station that the user will want to view the tram times for.</p><p>If you have multiple parameters you can define the combinations that are supported below. You can then define the <strong>Title</strong> and <strong>Subtitle</strong> of your intent; these will be displayed to the user when your shortcut is suggested by Siri.</p><p>If your action can run in the background then you need to check the option for <strong>‘Supports background execution’</strong>. Once you have defined your intent, you need to select the options in <strong>Target membership </strong>to have Xcode generate your Intent classes for you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*TXRuHh89eX5bTB1g50NvMA.png" /></figure><p>It helps if your classes can be generated in the target where your action is performed. This will be easier if your project’s main actions are separated into their own frameworks. Here I have separated all of my app’s data requests into my own custom framework <strong>‘Station Request’. </strong>I generate my Intent classes in this framework as this is where I want to donate the intent.</p><h3>Donating Intents</h3><p>Wow that was a lot of setup! Now, let’s write some code.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4041c055946d0034df9d0f86c55460de/href">https://medium.com/media/4041c055946d0034df9d0f86c55460de/href</a></iframe><p>Make sure you import Intents into the file used. Here I add an extension to my Station model code.</p><blockquote>If your project is supporting previous operating systems then you will need to annotate the Intent code you use with @available.</blockquote><p>If your intent code has been generated correctly in your framework, you will be able to use it here, ViewStationIntent. Create a new Intent and assign an <strong>INObject</strong> to your custom object parameter. Give it an identifier you will be able to handle later; I give it the station identifier. You also need to provide the name which will be shown for the custom object in the Siri Suggestion.</p><p>Here you can provide a <strong>suggested invocation phrase</strong>, which will be given to the user if they try to customise an invocation phrase for your intent.</p><p>Calling this function before I request new tram times for a station it will donate an intent for me:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f7dd0a532a43662941bf6c33787250e7/href">https://medium.com/media/f7dd0a532a43662941bf6c33787250e7/href</a></iframe><blockquote>Again making sure that I import Intents, iOS12 is available to use the Intents apis.</blockquote><p>Create an INInteraction using the intent we have just created. Then call donate. Siri will pick this information up and should start suggesting this action to your users when you are in a similar situation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/1*r-x-js9PBz4dBsdTvovb-w.png" /><figcaption>Found in Settings -&gt; Developer -&gt; Display Recent Shortcuts</figcaption></figure><p>You can debug this and make sure your intent is donated correctly by turning on the developer options. This will show your recently donated shortcuts on the lock screen.</p><p>If you are having problems, look at the error you received when donating the interaction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4EGVBtOYDuyRqX0nedTBEQ.png" /></figure><p>You can now add a custom phrase for this shortcut in the Siri &amp; Search page in settings. It didn’t seem to work for me in iOS12 beta 1; I had to wait for beta 2 to be able to save the shortcut phrase.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UzMrbvTiU70OlU4WmiOc_Q.png" /></figure><h3>Handling Shortcuts</h3><p>Once a user follows your shortcut, you will need to handle it in your App Delegate.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/149ce740959e73ae124415b71a99f890/href">https://medium.com/media/149ce740959e73ae124415b71a99f890/href</a></iframe><p>The userActivity contains the interaction you donated in the previous section. You can unwrap this and cast it into your custom Intent. I used this to get my station identifier back and can use it to request the latest tram time. This lets me open the app on the correct station page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*px_kGLNcdybuYMiW6F2Hzg.png" /></figure><h3>Conclusion</h3><p>In this first part I have shown you how to use the new Siri Intents api. In my next article I’ll show how to use <strong>Intent Extensions</strong> and<strong> Custom Intent Responses</strong> to respond to the user inline with Siri.</p><p>Look at my full implementation here:</p><p><a href="https://github.com/Winnie90/TFGMLive/tree/siriIntents">Winnie90/TFGMLive</a></p><p>I’m still going to be working on tidying it up and more work with the Siri watch face.</p><p>Thanks for reading! If you’re inspired, here are some useful links to help if you get stuck:</p><ul><li><a href="https://developer.apple.com/videos/play/wwdc2018/211/">Introduction to Siri Shortcuts - WWDC 2018 - Videos - Apple Developer</a></li><li><a href="https://developer.apple.com/documentation/sirikit/accelerating_app_interactions_with_shortcuts">Accelerating App Interactions with Shortcuts</a></li><li><a href="https://bendodson.com/weblog/2018/06/05/custom-intents-with-sirikit-ios-12/?">Custom Intents with SiriKit on iOS 12</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7d9eb87fd304" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>