<?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 Dave Schöttl on Medium]]></title>
        <description><![CDATA[Stories by Dave Schöttl on Medium]]></description>
        <link>https://medium.com/@enslaver?source=rss-af2e8d8704dd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*X5XZILQ9dpNL5FpqJANf5g.jpeg</url>
            <title>Stories by Dave Schöttl on Medium</title>
            <link>https://medium.com/@enslaver?source=rss-af2e8d8704dd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 15:56:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@enslaver/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[Adding a Simple Siri Shortcut to the homegate.ch iOS App]]></title>
            <link>https://medium.com/smg-real-estate/adding-a-simple-siri-shortcut-to-the-homegate-ch-ios-app-a7c3ee8d586?source=rss-af2e8d8704dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/a7c3ee8d586</guid>
            <category><![CDATA[sirikit]]></category>
            <category><![CDATA[siri-shortcut]]></category>
            <category><![CDATA[home-gate]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Dave Schöttl]]></dc:creator>
            <pubDate>Mon, 07 Jan 2019 15:26:46 GMT</pubDate>
            <atom:updated>2019-01-07T16:51:22.297Z</atom:updated>
            <content:encoded><![CDATA[<p><em>This post explains how the Siri Shortcuts feature ‘Repeat Last Search’ was added to the homegate.ch iOS App. It also describes some difficulties encountered and suggests some ways how this feature could be extended.</em></p><h3>Basic Idea</h3><p>The notion of having voice support in our App has been around quite a while now. Until the advent of iOS 12 only a hand full of very specific use cases could be handled via Siri — like setting up a work-out or ordering a ride, none of which was a fit for our Real Estate App. We explored the possibilities then in a Hackathon and were pretty unsatisfied with the result.</p><p>So when it was announced at WWDC’18 that some new take on Siri Integration was coming we were eager to give it another try.</p><p>When trying out new stuff you should think of two things:</p><ol><li>Have some basic target/idea you want to accomplish.</li><li>Start simple &amp; small — what’s the MVP?</li></ol><p>In our case I wanted to accomplish the following simple task: <em>Let the Siri Shortcut trigger our App to perform the last search, and then show the results.</em> Nothing more — nothing less.</p><h3>Where to Start?</h3><p>– of course: Read the f***ing manual! 🤓</p><p>Apple offers extensive documentation on the topic, the relevant of which can be accessed here (including an example App to get you started):</p><ul><li><a href="https://developer.apple.com/documentation/sirikit"><em>SiriKit</em></a><em> — General documentation about the SiriKit Framework</em></li><li><a href="https://developer.apple.com/documentation/sirikit/donating_shortcuts"><em>Donating Shortcuts</em></a><em> — Documentation about the process of donating a Siri Shortcut</em></li><li><a href="https://developer.apple.com/documentation/sirikit/soup_chef_accelerating_app_interactions_with_shortcuts"><em>SoupChef Example Ap</em></a><em>p — The SoupChef example App which was also shown at WWDC’18</em></li></ul><p>Of course there are also many articles on Medium which cover the topic. For example, here’s one which covers some more advanced aspects:</p><ul><li><a href="https://medium.com/@pietropizzi/a-beginners-guide-to-developing-custom-intent-siri-shortcuts-for-ios-12-a3627b7011af">A beginner’s guide to developing Custom Intent Siri Shortcuts for iOS 12</a></li></ul><h3>How do Siri Shortcuts Work?</h3><p>Basically, you donate <em>Intents</em> to Siri in response to certain actions taken in your App: Each time the user does some special thing (like: do a search) you donate a corresponding Intent.</p><p>By considering the frequency of occurence (how often does the user commit the action), as well as when such action is taken, SiriKit can predict user behavior and auto-magically present the user with the right shortcut at the right time (if you also happen to be in the FrontRow Search UI at that time…). This behavior works very well for actions that are repeated in regular intervals, like texting your wife that you’re on your way home, or in the example of the SoupChef App ordering your Tomato Soup for lunch each Friday.</p><p>Aside from this Assistant aspect you can also define a spoken phrase which will trigger the shortcut; you would say something like this:</p><blockquote>“Hey Siri: Repeat Last Search in Homegate!”</blockquote><p>The shortcut appears in the <em>Settings</em> App under <em>Siri &amp; Search</em> once you have donated the Intent. There you can define the magic words to invoke it.</p><p>After the shortcut has been activated then, depending on what you want to accomplish for your Use Case, you can do some processing in the background, present the User with a Notification Center-style UI (like for Rich Notifications), or open your App for further processing of the request.</p><p>In our case we want to go with the latter one: Open the homegate.ch App and show the results for the most recent search.</p><h3>Necessary Steps to Implement the Feature</h3><p>First some preliminary words which will spare you some head scratching:</p><ul><li>The Apple documentation which covers shortcut donation (see above) suggests that there are two different ways how to donate shortcuts: Either using <em>NSUserActivity</em> or <em>INInteraction. </em>I’ve tried them both, but only donating <em>INInteraction</em> objects actually worked.</li><li>It further suggests that you can add support for shortcuts either directly to you main App target, or via an App Extension. For my trivial Use Case the former approach seemed sufficient, and at the time when I first implemented the feature (a few months ago) it worked fine. When it came to writing this article I had to realize that this was no longer the case: Instead of switching to the App automatically Siri presented me with a button which I had to tap manually in order to open the App… <em>Yai!</em></li><li>So, don’t believe what the documentation says in this regard: <strong>If you want to add shortcut support to your App your really have to go with the App Extension approach.</strong> For anything more sophisticated than the trivial Use Case described here you would go with that approach anyway…</li></ul><h4>Step 1: Add an Intent Extension Target</h4><p>First you add an <em>Intent Extension</em> target to your main project. The App Extension will host the code which processes the Intent and does the necessary routing.</p><p>In Xcode this is done via:</p><blockquote>File → New → Target… → Intents Extension</blockquote><h4>Step 2: Add a SiriKit Intent Definition File</h4><p>Next you add a <em>SiriKit Intent Definition</em> file to your main project. In this file you can define the custom Intents which your App supports.</p><p>In Xcode this is done via:</p><blockquote>File → New → File… →<em> </em>SiriKit Intent Definition File</blockquote><p>Based on the Intent Definition file Xcode will generate a bunch of classes and protocols; both your main App as well as your Intent Extension need access to these. To make these artifacts visible select the newly created Intent Definition file in the project tree and, via the File Inspector UI, add it to your main <em>App</em> target as well as to your <em>Intent Extension</em> target.</p><h4>Step 3: Setup a Custom Intent</h4><p>Select the Intent Definition file in the project tree and use the ‘+’ button in the UIs ‘Custom Intents’ pane to create a <em>New Intent</em>.</p><p>Give the Intent a name, add a title/description and optionally define a Default Image to use (from the <em>Images.xcassets</em> Bundle). The image will later be visible in the Siri&amp;Search Settings UI. For my trivial Use Case no further setup is required.</p><p>In the Identity Inspector UI you’ll see a section ‘Custom Class’ which shows the name of the generated class that represents the Intent in code. Once you have built your project a small arrow appears next to the class name: Click it to inspect the generated interface.</p><p>Note that Xcode will automatically add the following entries to the <em>Info.plist</em> files in your targets:</p><ul><li>App Target: A <em>NSUserActivityTypes</em> array, holding the name of the generated Intent class.</li><li>Intent Extension Target: Under <em>NSExtension/NSExtensionAttributes</em> in the <em>IntentsSupported</em> array, the name of the generated Intent class.</li></ul><h4>Step 4: Implement IntentHandling Protocol in Extension</h4><p>In your Intent Extension Target you’ll find a pre-created file <em>IntentHandler.swift</em> which contains a stub implementation for a method <em>handler(for intent: INIntent)</em> that returns an object able to handle intent. The returned object must implement the matching generated <em>Intent Handling</em> protocol.</p><p>For more elaborate Use Cases you might want to implement the matching protocol in a separate class. For my trivial Use Case I found it to be sufficient to add an extension to <em>IntentHandler</em> implementing the protocol.</p><p>At the very least the method</p><blockquote><strong><em>public</em></strong><em> </em><strong><em>func</em></strong><em> handle(intent: HGARepeatLastSearchIntent, completion: </em><strong><em>@escaping</em></strong><em> (HGARepeatLastSearchIntentResponse) -&gt; Void)</em></blockquote><p>must be implemented. <em>Hint: You won’t find that method in the generated interface — it just exists somehow, somewhere…</em></p><p>Be that as it may, the method should instantiate a new <em>Intent Response</em> object with a response code that reflects your desired outcome; in my case this is <em>.continueInApp</em> (see generated class for possible values). This object then must be passed to the completion handler.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zhwhkMV7u0BpL74NdiGf2g.png" /><figcaption>Simple Intent Handler implementation (Swift)</figcaption></figure><p>That’s all that needs to be done for this part. Moving on…</p><h4>Step 5: Donate Intent in App</h4><p>The next step is to actually <em>donate</em> an intent when the user performs a certain action; in our case this when the user taps the search button to initiate a search.</p><p>This might look something like in the following snippet:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_v3l9Z_Jb_qSbKch5SWPBg.png" /><figcaption>Setting up and donating an Intent (Objective-C)</figcaption></figure><p>An instance of the generated Intent class is created and further customized by setting the <em>suggestedInvocationPhrase</em> property with a localized string. This string is an example phrase the user <em>could</em> say to invoke the shortcut and is displayed in the UI where the user can setup the short cut.</p><p>The instance of the Intent is then used to initialize a new <em>INInteraction</em> object.</p><p>Finally, to actually donate the Intent, the <em>donateInteractionWithCompletion:</em> method is called on the object.</p><h4>Step 6: Handle Intent in App</h4><p>To recap, in Step 4 we are telling SiriKit <em>how</em> the intent should be handled (“Continue in App”), and in Step 5 we are <em>donating</em> the interaction in response to an action taken by the user (“Perform Search”).</p><p>The final step is to react correctly when the short cut is invoked and passed to the App in the form of an <em>NSUserActivity</em> object. This is done by implementing the <em>UIApplicationDelegate</em> method</p><blockquote>- (<strong>BOOL</strong>)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(<strong>void</strong> (^)(NSArray * <strong>_Nullable</strong>))restorationHandler</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k069OWupjgo0Cw2Fo0tjIg.png" /><figcaption>React to received NSUserActiviy object (Objective-C)</figcaption></figure><p>The content of the <em>userActivity.activityType</em> property matches the class name of the generated <em>Intent</em> class and can be used for deciding how to react. In our case this entails the retrieval of the most recent Search Parameter object and passing that on to the UI so it can initiate the Search.</p><p>That’s it: By following the steps described in this article you can add simple support for Siri Shortcuts to your App — and of course extend from there. 🎉</p><h3>Where to Go from Here</h3><p>At the point of writing this article the feature shown here isn’t yet released in our App; we’ll probably include it in <em>homegate.ch v10.1</em>.</p><p>There is a trend that more and more functionality goes into System-provided UIs, so the user doesn’t have to actually enter your App in order to get things done. We know this already from <em>App Widgets</em> and <em>Rich Notifications</em>, and <em>Siri Shortcuts</em> are no exception to this.</p><p>One example how the described Use Case could be improved is to perform the last search and display the results directly in a Shortcut UI, instead of switching to the App. This requires some additional work (including an extra UI Extension Target) and might be covered in a follow-up article. Stay tuned!</p><p>If you liked this article and it was helpful to you please add some claps!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a7c3ee8d586" width="1" height="1" alt=""><hr><p><a href="https://medium.com/smg-real-estate/adding-a-simple-siri-shortcut-to-the-homegate-ch-ios-app-a7c3ee8d586">Adding a Simple Siri Shortcut to the homegate.ch iOS App</a> was originally published in <a href="https://medium.com/smg-real-estate">SMG Real Estate Engineering Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>