0

I want to check if the specified with identifier app is active and at front most, I used like below but it got isRunning status only, how can I know if the app is at front most?Thank you.

#import <SBApplicationController.h>
#import <objc/runtime.h>
#include <dlfcn.h>

@interface SBApplication : NSObject
- (BOOL)isRunning;
@end

BOOL isAppFront(const char * appIdentifier)
{
    NSString *appId = [NSString stringWithUTF8String:appIdentifier];
    SBApplicationController *appController = [objc_getClass("SBApplicationController") sharedInstance];
    SBApplication *app = [appController applicationWithDisplayIdentifier:appId];
    return [app isRunning];
}
Suge
  • 2,808
  • 3
  • 48
  • 79

0 Answers0