Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Launching an app from Pythonista
-
It used to be that only those apps which published an URL scheme could be launched from another app (and not all apps did so, meaning that some apps could simply not be launched from Pythonista).
It would seem that things have changed with the advent of the Shortcut apps, which now has an 'Open app' action, whose list of apps seems to be quite exhaustive, i.e. even those apps which do not publish an URL scheme are available. (Shortcut's predecessor, Workflow, did not have this feature).
Does anyone know if this functionnality can be used from Pythonista, and how ? Or this an Apple-only API that is reserved to Shortcuts ?
-
@TPO Shortcuts has even something better than "Open app", it is "Open In app" and you can transfer a file to this app, even to apps without url scheme.
I have asked how they do that by a mail to the old email of the Workflow support but without any answer, as usual 😢 for Apple. -
@TPO, is this a general question or did you have a specific app in mind? There was this method to find the launch URL of ”any” app, wonder if it still works.
-
@cvp, both "Open app" and "Open in app" would be very useful to me, but I am afraid they will turn out to use Apple-restricted APIs :-(
@mikael, indeed, this method used to work, but only for those app which publish an URL-scheme, and not all of them do. Plus, the method relied on app synchronisation via iTunes (to get access to the app's .ipa package), and that is now gone.
A possible workaround would be to define a one-line Shortcut script for each app to be launched (action = "Open app", arg = "App"), and call this script from Pythonista. I was looking for something less clumsy ;)
-
i read somewhere that shortcuts under the hood was using url schemes. not sure if it just auto detects available schemes, or what.
There is also some sort of INIntent and NSUserAction that apps can publish, but it doesnt seem like another app has access to those... but perhaps through sirikit.
shortcuts itself seems to offer url schemes, so it seems like you would be able to have pythonista launch shortcuts, and return via x-callback-url?
https://www.reddit.com/r/shortcuts/comments/9gvrop/i_created_a_shortcut_to_get_the_url_scheme_link/
-
as an aside, doing an itunes backup, then using iMazing, i think that gets you app .plists. not 100% sure, but i was digging through my pythonista back the other day and was able to see it, though im on an older, nonencrypted device
-
@TPO Just to test:
- create a shortcut with only "Open In" with an app you don't know the url scheme
- in my example, app is "Gaia GPS"
- In Shortcuts app, share the shortcut "as a file"
- import this file in your preferred editor (I import it in Pythonista and rename it as .txt)
- you will see something like
bplist00× _WFWorkflowClientVersion_WFWorkflowClientRelease^WFWorkflowIcon_WFWorkflowImportQuestions_WFWorkflowActions_WFWorkflowTypes_!WFWorkflowInputContentItemClassesU754.2U2.1.3Ó _WFWorkflowIconStartColor_WFWorkflowIconImageData_WFWorkflowIconGlyphNumber½ÿ@èw ¡Ò_WFWorkflowActionIdentifier_WFWorkflowActionParameters_is.workflow.actions.openinÒ_WFOpenInAskWhenRun_WFOpenInAppIdentifier_com.trailbehind.GaiaGPS.ng¢XNCWidgetXWatchKit¯ !"#$%&'()*+,-./0_WFAppStoreAppContentItem_WFArticleContentItem_WFContactContentItem_WFDateContentItem_WFEmailAddressContentItem_WFGenericFileContentItem_WFImageContentItem_WFiTunesProductContentItem_WFLocationContentItem_WFDCMapsLinkContentItem_WFAVAssetContentItem_WFPDFContentItem_WFPhoneNumberContentItem_WFRichTextContentItem_WFSafariWebPageContentItem_WFStringContentItem_WFURLContentItem���1�K�Z�v���À�Æ�Ì�Ó�î$)*-.05Ro¦¾¿Üßèñ 7Nb~®Ëãý'BZw�������������1��������������
Check
WFOpenInAppIdentifier_com.trailbehind.GaiaGPS
Take the last word, and try
webbrowser.open('GaiaGPS://')
Edit: if it is ok with your app, we could of course make a little script which reads the shortcut file and extracts this last word.
Edit: the list of apps proposed by Shortcuts "Open In" is not exhaustive at all...
- create a shortcut with only "Open In" with an app you don't know the url scheme
-
@cvp, I am testing with app "MyLifeOrg 3", which does not publish an URL Scheme. Using your method, I get the following identifier : 'net.mylifeorganized.MLO2'. However, opening URL 'MLO2://' fails ("Safari cannot open the page, the address is not valid").
Needless to say, the app is available as a target for the "Open app" action in Shortcuts...
I have come across the following (https://talk.automators.fm/t/shortcuts-url-scheme/1940/3) : Shortcuts still supports the Workflow URL Scheme, which means one can use the following URL : 'workflow://run-workflow?name=Test' to open the app. (Where 'Test' is the name of the Shortcut script, which contains one action : 'OpenApp MyLifeOrg 3')
However, this is clumsy, as :
- First, Safari asks for confirmation ("Open this page in "Shortcuts" ?) : @JonB : you guessed right !
- Second, the Shortcuts app appears briefly
- Third, at last the target app is displayed
Other suggestions and ideas on how to launch an arbitrary application, even if it does not publish an URL Scheme, are welcome !
Edit : have also tried the "official" Shortcut URL Scheme, using the method described in https://talk.automators.fm/t/shortcuts-url-scheme/1940/2: shortcuts://x-callback-url/run-shortcut?name=Test&id=CD61E01D-22CF-43B8-966B-19AA134F0456&source=homescreen. The result is the same as with the old Workflow URL Scheme above.
-
@TPO Sorry, before my post, I've tried some installed apps, successfully.
And now, I've tested some other ones, like Documents of Readdle, but without success.
Sorry for waste of time
that would have been a good solution -
@TPO I think I've found a solution.
The shortcut file contains as WFAppIdentifier the application BundleID, and there is a Private API to Open an app via its BundleIDExample, this script opens the Apple Files app
from objc_util import * LSApplicationWorkspace = ObjCClass('LSApplicationWorkspace').alloc() BundleID = 'com.apple.DocumentsApp' LSApplicationWorkspace.openApplicationWithBundleID_(BundleID)
I've tried with net.mylifeorganized.MLO2 and it works 🍾
Edit: found here
-
@cvp, it works, you're the greatest !!!
-
@TPO Ho not at all, but Google is my friend 😂
Édit: Really, I don't know what a Private API is and if it is allowed to use it. Hoping somebody will explain us.
-
My God, I've just found this , thus I wasn't the first 😂