Making the best possible App – Part 2: App Intents, Shortcuts and accessibility

In part 1, we talked about adding Widgets, Quick Actions and more… We continue our App improvements with App Intents, Shortcuts and accessibility.

App Intents and shortcuts

As a user, you probably have no idea what App Intents are, and that’s normal. An App Intent, is a way an app allows the system (iOS, macOS…) to interact with the app. This way a developer can build on functionality of other apps and the OS.

An example could be a notes app that allows you to create a new note (from another app). In our case we allow an App to convert a date from one calendar to another. These App Intents are often made available though Shortcuts. These shortcuts can be given parameters to work with, and a shortcut can also return or display results, which can be used in another app or another shortcut. iOS, iPadOS and macOS all have Apple’s Shortcuts app to do the magic for you.

In the case of our Calndars app, we provide just one shortcut. The apps basic functionality is converting a date from one calendar to another. The inputs therefore are a date and a calendar, and the result is the date of the output calendar. Simple.

To make this work, you need to use the shortcuts app from Apple. To be honest I didn’t use the Shortcuts App a lot before this exercise. But once you get the hang off it, it is quiet powerful. I also understand this isn’t for everybody. Here is how Apple explains shortcuts.

In the case of the Calndars app, you can use something like this. This shortcut is set to convert to the Chinese Calendar. Input can be from manual, but you could get input from another shortcut… The result (text) will be copied to the clipboard.

Shortcuts can also be accessed by AppleScript on macOS. For those who know how to script, this can be very interesting. An example is shown below. In the example, we set the date to today, we made a shortcut to convert to the Hebrew calendar, and we ask to convert it. The shortcut will copy the result as a text to the clipboard. We than open the Notes App, create a new note, and paste the text from the clipboard.

tell application "Shortcuts Events"

      -- set theDate to current date

      set theDate to date "Saturday, 25 December 2004 at 00:00:00"

      run shortcut "Get date from Hebrew Calendar" with input theDate

end tell

tell application "Notes"

      activate --make sure Notes is running

      set theNote to make new note

      tell default account to tell folder "Notes"

            set body of theNote to the clipboard

      end tell

end tell

Technical rework of the app

The way the app was setup, wasn’t perfect. For each calendar there was a different view. This means there was a lot of code duplication. We rewrote the code so that all calendars are shown with just one view. The code is a bit more complex, but now there is no more code duplication, and the app has a smaller footprint. This is also easier to maintain. This was also a good step in supporting VoiceOver. This way we only needed to implement it once.

Accessibility

VoiceOver is an accessibility technology from Apple, that allows you to navigate your app in different ways. This allows people with disabilities to use your app.

Family sharing

I never looked at Family Sharing and I have never used it. So when somebody asked me if an app supports Family Sharing, I had to look for it. Turns out it is by default enabled, so I didn’t have to do anything to enable it. In case you work with subscriptions of in-app purchases, you need to implement it.

Making the best possible App – Part 3: AppleWatch, SwiftUI and delete…