How can I know that a special app is running right now - ios

Recently I need to develop an app that has a feature like this
If I download an app from the App Store,I want to know that whether the app has ever launched, Or how can I make sure that this app is running right now(no matter it's in the background or it's active)?
Now I can get all installed apps using LSApplicationWorkspace & LSApplicationProxy
And I can also get the running progresses right now using <sys/sysctl.h>'s stuff which could only provide me the progressName (probably its named with the app's project name)
Can anyone else help me with this?

Related

Running iOS app in the background without user interaction

Hey all I’m new to the world of Xcode and building apps.
I am wondering if it were possible to have an app run in the background and have it listen to the photos library and if it finds a new photo has been added it would automatically upload that to some type of rest api call without the user having to interact/do it manually?
This will only be used in my household so I’m not looking to get it into the App Store or go through any approval process that apple does if it were going to be in the App Store.
So before I spend too much time looking around - is this possible with iOS 14+? Only thing I have come across that remotely sounds like something that would work would be this PHPhotoLibraryChangeObserver but I’m not sure if the user has to interact with it in order for it to be used or not? I’m open to any suggestions you more experienced Xcode programmers have about the above.

Force iOS app to open in foreground using private APIs

I'm currently working on a kiosk type application that won't be distributed on the App Store. The device will sometimes need to switch applications to handle some other tasks, but in the case where a user doesn't manually switch back, I need my app to come to the foreground after a set amount of time has passed.
We don't have control over the other apps, so getting them to switch to ours after a timeout isn't possible.
I know this can't be done through official means, but I'm asking if anyone knows of a private API I could call from within a scheduled notification that will foreground my application.
I have a feeling that this cannot be done without a jailbreak due to the sandboxing nature of the apps, as in, there's no way to send a message to whatever service launches apps on the device. Although it should be possible, as the demo devices in the Apple stores are able to revert back to a demo "screensaver" app if left alone for a while. What are they doing to achieve this?
If there is a jailbreak hack for this to work or a config or something an MDM service could handle, I'd be happy to try that out.
Again, this is for a private application that will not be distributed on the App Store. The app will be placed on devices located throughout our building and running on our internal network.
Via Jailbreak you could look at something like AutoLaunch:
If you use a particular app that seems to crash here and there, then a new free jailbreak tweak called AutoLaunch could be your next best friend. It can automatically re-launch any app that crashes on your device so you don’t have to re-launch it yourself.
http://www.idownloadblog.com/2017/01/08/autolaunch/
Not sure how much control you'd have over wanting to launch regardless of whether it's crashed or not. You might be able to ask the author to provide the source-code or work with him to get your desired result.
UPDATE:
It's open source:
https://github.com/chenzhijie/autolaunch
Upon further inspection of the source it looks like it uses the following to launch the application after a crash:
int createSubProcessResult = fork();
if(createSubProcessResult == 0) {
execl("/usr/bin/open","open",[currentAppBundleId UTF8String],NULL);
}
I guess you could roll your own version of Autolaunch and have it wait/subscribe for a remove command that'll launch/switch different apps.

Launch game from iOS app and return to it once closed

I have developed an app and I want to run another app installed on the phone and downloaded from the store (a game) inside a portion of the screen.
As I understood from my search, this is not possible. The next best solution would be to launch the game from my app and always return to it once the game closes.
I have been able to bootstrap a solution with a particular game using URL Schemes but is there a general solution working with any app downloaded from the store?
Do the answers provided there still apply or is it now possible? Can you run an iOS app inside another iOS App
No, you still can not run an app within another app.
The only way to launch another app from your own is by using URL schemes, and there is no way to make a third-party app reopen your original app once the user completes a game.
You cannot directly obtain a list of installed applications to launch, but you could use iHasApp and possibly your own dataset of known URL schemes to check if a given app is installed on the device.

ios 8 openUrl itms-services does not exit current app

In iOS 6 or 7, the app exit to the home screen when I call UIApplication openUrl with a url of itms-services://XXXX to install a new version of my app (using enterprise deployment with ipa files).
In iOS 8, this is no longer the case. Now the app continue running just as nothing has happened, but if I go the home screen, I can see my app icon grayed out, with a downloading pie chart about 66% completed and the text "Downloading..." below. If I now wait for a while (less than a minute), the application is installed correctly and I can start my app again.
Has anyone else experienced this behavior? Have anyone seen any documentation regarding this? I can accept behavioral changes as long as it is documented, but I haven't seen any documentation regarding this.
While forcing the app to crash will technically work, a much better solution (allowing the user to retain the state of the application) would be to simply background the app launching the itms-services link by executing the following.
[[UIApplication sharedApplication] performSelector:#selector(suspend)];
We use this in an app used for distributing test builds to our testers and it works very well, and eliminates the confusion of a tester trying to install an app and having the app stay in front. It also allows them to return to our distribution app and have it pick up where they were.
Yes, you also get the same behaviour when clicking a download link in safari now on iOS8.
I'm not sure why they introduced this change but there isn't really a way around it (unless you force your app to crash with something like exit(0);)
Also, the itms-services url scheme is undocumented and is technically a private api. From experience, you're not allowed to submit apps to the App Store that use it.
I have experienced a similar thing. I have a web page for our internal app store and when I tap on the link I do get a prompt asking if I want to install and when I say yes safari just sits there. The app is downloading on the home screen but under IOS 7 safari would be pushed to the background and you could see where your app is being downloaded to and its progress. Now it appears like nothing is happening. I would love to correct this. Perhaps something has changed in the .plist files the itms-services protocol uses. This protocol is not private it is just reserved for enterprise deployments.

How to removed killed app from recently used list (iOS)

I am developing a helper for an automated testing suite. There is a requirement to kill/reset the application being tested, so the app can be started again "fresh".
I know killing an app is against Apple guidelines; there are many questions here about that with sensible answers ("don't do that!"), but this is a different scenario; and the app will never be on the App Store (as it has been instrumented for testing purposes).
Currently, our helper calls "exit(0)" from within the app to terminate it. This works fine, but the app icon is left in the recently used apps list (double click home button).
I need a way to programatically remove the icon from the list (or, terminate the app in such a way the icon does not remain). Or maybe a way of refreshing this list somehow. The only way I have found so far is to uninstall the app and install it again.
This must work on the device (as well as the simulator). I can use solutions that make use of USB-only functionality (e.g. provided by libimobiledevice and friends), or calling a function inside the app, or a Private API call. Assume the device has a development profile on it. Jailbreaking is not an option.

Resources