Deeplink for importing a shortcut

Hello

I am currently in computer science university and doing my first internship. I got the task to create a mac app that automatically activates a pre-specified focus mode whenever the user has a meeting (checks the calendar). As a first step I am trying code an app that finds out if a focus mode is already on, and which one. There is no official API from apple or something like that if I’m right, so I thought to use shortcuts.

I already created a shortcut that checks which focus mode is on and displays this on screen. No problem there. I even managed to create a simple app with a button that, if clicked, executes the shortcut via a deeplink. Works all fine. Now I obviously can’t demand the user to create the shortcut by hand, so I need to import my shortcut programmatically. I found a scheme for a deeplink that does exactly that: shortcuts://import-shortcut?url=[url]&name=[name]

But I’ve been stuck on this for days now. It won’t accept a url to a locally stored file, no matter what, there’s always the error message that the file doesn’t exist. (shortcuts://import-shortcut?url=file:///Users/LarsWuethrich/Uni/Informatik/PSE/FocusModeTest/Focus.shortcut&name=Focus)

Then I tried linking to a download link to a shortcut on github. (shortcuts://import-shortcut?url=https://github.com/Wii42/FocusSync/raw/main/Bastien%26Lars/Focus.shortcut&name=Focus) now all seems to work, the shortcut app opens, and no error message, but after a few seconds it suddenly crashes without importing.

Is this a bug on Apple's side or did I mess something up? Or do you have any other idea on how to read if a focus mode is on or to maybe create a shortcut programmatically? Thanks in advance

Lars

Deeplink for importing a shortcut
 
 
Q