问题
I found this and the problem is that the answers on that question didn't pan out (I also tested them first) and also that it is over a year old.
I've used the solution here to fetch the list of all running processes, but not of the struct kinfo_proc attributes seem to give any useful in detecting which app is currently visible to the user.
Basically:
I am trying to find out which app is currently visible (and open) to the user on iOS devices. It must work on stock devices (non-jailbroken) and no need to worry about the app store.
Edit: I am looking at the private APIs now, but cannot seem to determine how my app could be notified (or inquire) about a new application being brought to the front.
Thank you
回答1:
Thanks to @JohnWoods in the comment section of the question, I was able to find the solution on a related question.
The solution I used and that worked for me was here.
来源:https://stackoverflow.com/questions/20200385/programmatically-detect-which-ios-application-is-visible-to-user