使用PrivateFrameworks SpringBoardServices在iOS8,iOS9中不起作用, 我可以获得后台所有进程,但是它在前台运行?
(void) monitoringFrontApp {
mach_port_t *port;
void *uikit = dlopen(SPRINGBOARDPATH, RTLD_LAZY);
int (*SBSSpringBoardServerPort)() =
dlsym(uikit, "SBSSpringBoardServerPort");
port = (mach_port_t *)SBSSpringBoardServerPort();
//dynamic link sys mothed
void* (*SBFrontmostApplicationDisplayIdentifier)(mach_port_t* port,char * result) =
dlsym(uikit, "SBFrontmostApplicationDisplayIdentifier");
//call mothed
char frontmostAppS[256];
memset(frontmostAppS,sizeof(frontmostAppS),0);
SBFrontmostApplicationDisplayIdentifier(port,frontmostAppS);
NSString * app_id = [NSString stringWithUTF8String:frontmostAppS];
NSLog(@"front display app Identifier----%@", app_id);
//dynamic link sys mothed
CFStringRef (*SBSCopyLocalizedApplicationNameForDisplayIdentifier)(CFStringRef displayIdentifier) =
dlsym(uikit, "SBSCopyLocalizedApplicationNameForDisplayIdentifier");
//call mothed
CFStringRef locName = SBSCopyLocalizedApplicationNameForDisplayIdentifier((__bridge CFStringRef)app_id);
NSString *app_name = [NSString stringWithFormat:@"%@",locName];
if (locName != NULL)CFRelease(locName);
NSLog(@"front display app name----%@", app_name);
}
在iOS8和iOS9中不起作用