Identify in pythonista_startup if app launched via its url scheme
Is it possible, in pythonista_startup script, to know if app has been normally launched or via its url scheme? I want to process something different if launched via an home screen shortcut with action=run
JonB last edited by
Pythonista_startup is not guaranteed to run, for instance if app was already open.
I think u have to handle it in the script being run. Maybe something in sys.argv...
You can swizzle application_did_resume, and iirc has an options dict that let's you know it was asked to launch a script.
@JonB Thanks for your answer.
I want to explain why I ask this question.
On my iPad I have the app always started, it is my biggest hobby, thanks to @omz 😀.
On My wife's iPad, she only uses this app via home screen Shortcuts.
Some years ago, I already asked to omz if it would possible that at start of his app, an image would be displayed during the startup process, instead of the editor tabs.
In my normal pythonista_startup, I launch my menu with toolbar button and the objectivec crash log, then I agree to come in editor tabs.
But in the Pythonista _startup if launched by an home screen shortcut, I would only quickly display a "wait image/gif" until the real script starts.
Hoping I 'be been clear enough 😅
JonB last edited by
Try checking sys.argv in pythonista_startup. If launched from a urlscheme, I think the script name will be in sys.argv, whereas from a normal app launch, it won't. (I might be wrong... It may be that sys.argv gets set later.)
@JonB I had tested that one hour ago but argv empty in startup
Pythonista_startup runs first for Python 2 and in this case I run a little script to display a gif, it appears enough quickly. Then, it runs for Python 3 and in this case I do my special process for objectivec crash log and my toolbar button.
# coding: utf-8 import os import ui path = os.path.expanduser('~/Documents/wait.gif') wv = ui.WebView() wv.load_url(path) wv.present(hide_title_bar=True)
Several tests show that the order of pythonista_startup is sometimes 2-3 and other time 3-2
Thus not yet the good solution...
Edit: url scheme allows parameter version= thus startup runs only once 🍾
You can swizzle application_did_resume
But, when I receive the hand in Pythonista_startup , is that not already too late?
"application_did_resume" has already been called, no?