Open mihir-io opened 2 years ago
It looks like the required background setting (https://github.com/rickyzhang82/tethering/pull/21/commits/b8853647c04cc37b1a2034feff1266cd44fe98b5#diff-254bfc078464eb1d3425c3738622feae070116053ddedc5505023322c63f6045) isn’t in Pythonista’s current Info.plist; indeed, UIBackgroundModes doesn’t seem to be set at all. What that means is that there’s no way that I know of to make the script run in the background forever, since the Pythonista app does not declare that capability. It doesn’t rule out the possibility of using some private framework to achieve that goal, if such a private API exists.
The black screen workaround seems like a good approach in the meantime; if you would like to submit a PR for that I’d gladly take a look.
@nneonneo I opened up a PR, though honestly it's a bit hacky so I'm not thrilled about it. Feel free to check it out and merge or reject it. I might revisit it and see if there's a more refined way to accomplish it.
I found some private APIs that can be used to keep the app alive while the device is awake, but there is nothing we can do while the device is off. Perhaps we should reach out to the developers of Pythonista?
@regulad Hey! Unfortunately I doubt they'll be able to help -- Apple won't allow the app on the app store if it uses private APIs.
@regulad Hey! Unfortunately I doubt they'll be able to help -- Apple won't allow the app on the app store if it uses private APIs.
A private API isn't needed to keep it alive, only a plist change to enable getting location, Bluetooth, or playing audio in the background. All have legitimate uses.
I found some private APIs that can be used to keep the app alive while the device is awake, but there is nothing we can do while the device is off. Perhaps we should reach out to the developers of Pythonista?
If the private API is accessible just from a private framework and doesn't require special permissions, it may be possible to call it from Pythonista :)
Maybe we should petition the Pythonista devs to add the "background location" permission to their app. After all, it's a sensible permission to give people to play with, and it simultaneously unlocks so many more use-cases.
Is there any way to keep the proxy alive while the screen is off? Everything works fine for me while the screen is awake, but once I turn if off, the proxy connect dies after a few seconds/minutes.
I know this is probably a limitation of iOS and Apple's App Store requirements for Pythonista, but is there any workaround? I know some apps are able to keep themselves alive by playing a background audio track. Is there some kind of integration point in Pythonista that would allow playing a silent MP3 on loop or something?
For comparison, https://github.com/rickyzhang82/tethering seems to be working fine in the background, though of couse, it's an app that's sideloaded so it probably isn't up to the App Store requirements.
Edit: Or as an alternative, maybe to use Pythonista's
ui
module to keep the screen on, but display a full screen, solid black image? That way even if the display is technically on, it's all black, so modern iPhones with OLED displays (and in particular, the 13 Pro's ability to scale down to 10Hz) will conserve battery life and screen burn-in health.