Things are way easier than what would one think. I found out that this brings the answer:
SBApplication *front = [[objc_getClass("SpringBoard") sharedApplication] _accessibilityFrontMostApplication];
NSString *runner = front.bundleIdentifier;
Question
My question differs than the other ones, because I am coding for a jailbroken environment. The method I am editing belongs to SpringBoard and creates a system wide change, on all apps. Using this command:
[[NSBundle mainBundle] bundleIdentifier]
Only brings SpringBoard, as this method belongs under SpringBoard. So is there a way to tell which app is active in front of SpringBoard?
La solution 2
Things are way easier than what would one think. I found out that this brings the answer:
SBApplication *front = [[objc_getClass("SpringBoard") sharedApplication] _accessibilityFrontMostApplication];
NSString *runner = front.bundleIdentifier;
Autres conseils
There is -(NSString*)topApplication
method in BKSWorkspace
class which returns bundle identifier of a top-most application. In order to get a valid instance of BKSWorkspace
you need to hook it's -(id)init
method to retain and store an instance for yourself. SpringBoard stores these instances in such a way that you can't access them without hooking init
.