Keeping Your Shortcuts Up to Date With RoutineHub and UpdateKit
Learn to update your Apple Shortcuts seamlessly using RoutineHub and UpdateKit. Keep your shortcuts fresh and your users satisfied!
You’ve just crafted the world’s greatest Apple Shortcut, but here’s the twist: you need a reliable way to update it without driving yourself (or your users) bananas. Enter RoutineHub and UpdateKit, your new best friends in the shortcut universe.
So, what’s the deal with https://routinehub.co? Think of it as the GitHub for Shortcuts. Every time you whip up a new version of your shortcut, you can post the new iCloud URL on RoutineHub. The beauty part? Your users only need to remember one RoutineHub link. That’s right—just one link to rule them all!
Now, here’s the kicker: you want to update your shortcut again (because you’re a perfectionist, of course), and you want to make sure the shortcut checks for updates by itself. Sounds like magic, right? Well, let’s pull a rabbit out of our hat with UpdateKit.
You know how Linux Redhat, Raspberry Pi, macOS Homebrew, and Node Package Manager have those nifty automatic update checkers? Apple Shortcuts has its own hero in the form of UpdateKit.
UpdateKit is like your shortcut’s personal assistant, always on the lookout for new versions on RoutineHub. Let’s dive into how you can get this setup with Jellycuts (no wands required).
Add this code to your shortcut, and voila! Every time your shortcut runs, it’ll check if there’s a new version. Your users will get a friendly nudge to update, ensuring they always have the latest and greatest.
// ——— About [Shortcut Name] ———
dictionary(json: { "name": "MyShortcut", "version": "0.0.1", "RH_ID": "[RoutineHub ID]", "author": "https://routinehub.co/user/[authorname]", "RH_URL": "https://routinehub.co/shortcut/[RoutineHub ID]" }) >> metadata
// ——— Start Updater —————
alert(alert: "Checking for Shortcut Updates…", title: "Shortcut Update Manager", cancel: true)
var updateURL = "https://updatekit.mikebeas.com/v1"
valueFor(key: "RH_ID", dictionary: metadata) >> rhID
valueFor(key: "version", dictionary: metadata) >> appVersion
deviceDetails(Device Model) >> deviceModel
deviceDetails(System Version) >> systemVersion
var currentVersion = {"shortcut": {"module": "routinehub", "id": "${rhID}", "version": "${appVersion}"}}
downloadURL(url: updateURL, method: POST, headers: {}, requestType: Json, requestJSON: currentVersion) >> updateResponse
valueFor(key: "update", dictionary: updateResponse) >> isAvailableForUpdate
if(isAvailableForUpdate == "Yes") {
valueFor(key: "payload", dictionary: updateResponse) >> updatePayload
valueFor(key: "download", dictionary: updatePayload) >> iCloudLink
valueFor(key: "version", dictionary: updatePayload) >> updateVersionID
valueFor(key: "RH_URL", dictionary: updatePayload) >> RH_URL
alert(alert: "Update to ${updateVersionID} Available", title: "Update Status", cancel: true)
// Go to RoutineHub Listing to Learn More about the Shortcut
openURL(url: RH_URL)
exit()
} else {
alert(alert: "No Update Required", title: "Update Status", cancel: false)
}
// ——— End Updater ——————
// ——— Start Your Application Below ——————
Detailed Breakdown
Explanation of the Code for New Users
This code helps you check for updates to your Apple Shortcut using RoutineHub and UpdateKit. Here’s a step-by-step breakdown of what each part does:
Metadata Section
// ——— About [My Shortcut] ———
dictionary(json: { "name": "MyShortcut", "version": "0.0.1", "RH_ID": "[RoutineHub ID]", "author": "https://routinehub.co/user/[authorname]", "RH_URL": "https://routinehub.co/shortcut/[RoutineHub ID]" }) >> metadata
Think of this code part as both good hygiene and utility. This JSON-based dictionary details your shortcut, such as its name, version, RoutineHub ID, and author information.
As you continue to update your Shortcut, all you need to do is modify version and the rest of this updater will work perfectly.
Start Updater Section
// ——— Start Updater —————
alert(alert: "Checking for Shortcut Updates…", title: "Shortcut Update Manager", cancel: true)
This shows a pop-up alert to inform the user that the shortcut is checking for updates.
var updateURL = "https://updatekit.mikebeas.com/v1"
Defines the URL for UpdateKit’s server, which will handle the update check.
valueFor(key: "RH_ID", dictionary: metadata) >> rhID
valueFor(key: "version", dictionary: metadata) >> appVersion
deviceDetails(Device Model) >> deviceModel
deviceDetails(System Version) >> systemVersion
These lines extract the RoutineHub ID, current version, device model, and system version from the metadata and device.
var currentVersion = {"shortcut": {"module": "routinehub", "id": "${rhID}", "version": "${appVersion}"}}
Creates a JSON object with the current version details of your shortcut. When the Shortcut first loads, it will send this JSON payload to UpdateKit to determine if a new version is available.
downloadURL(url: updateURL, method: POST, headers: {}, requestType: Json, requestJSON: currentVersion) >> updateResponse
Sends a request to the UpdateKit server to check if there’s a new version available.
valueFor(key: "update", dictionary: updateResponse) >> isAvailableForUpdate
Checks if an update is available from the server response.
Update Check Section
if(isAvailableForUpdate == "Yes") {
valueFor(key: "payload", dictionary: updateResponse) >> updatePayload
valueFor(key: "download", dictionary: updatePayload) >> iCloudLink
valueFor(key: "version", dictionary: updatePayload) >> updateVersionID
valueFor(key: "RH_URL", dictionary: updatePayload) >> RH_URL
alert(alert: "Update to ${updateVersionID} Available", title: "Update Status", cancel: true)
openURL(url: RH_URL)
exit()
} else {
alert(alert: "No Update Required", title: "Update Status", cancel: false)
}
- If an update is available (
isAvailableForUpdate == "Yes"
), it retrieves the update details (updatePayload
) including the download link (RH_URL
) and new version ID (updateVersionID
). - Displays an alert to the user that an update is available.
- Opens the iCloud link to download the new version.
- If no update is needed, it shows an alert saying "No Update Required".
End Updater Section
// ——— End Updater ——————
This indicates the end of the update checker code.
Summary
- Metadata: Sets up shortcut details.
- Start Updater: Displays a checking alert and prepares update details.
- Update Check: Checks for updates and prompts the user if an update is available.
- End Updater: Ends the update script.
This script ensures your shortcut users always have the latest version, making the updating process smooth and automatic.
Conclusion
RoutineHub and UpdateKit are like the dynamic duo of the shortcut world, making it super easy to keep your creations up to date. With these tools, you can focus on creating awesome shortcuts while they handle the updates. Happy shortcutting!