Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get currently foreground running app (third party) bundle Identifier

How to get application name running in foreground? it was working in iOS 7 using SpringBoard but in iOS 8 I don't get the result. Any help is appreciated. I don't need to submit my app on apple store so if any patch or script also available then please let me know.

Code is working fine on below iOS 8.0

- (NSMutableString*) getActiveApps
{
mach_port_t *port;
void *lib = dlopen(SBSERVPATH, RTLD_LAZY);
int (*SBSSpringBoardServerPort)() =
dlsym(lib, "SBSSpringBoardServerPort");
port = (mach_port_t *)SBSSpringBoardServerPort();
dlclose(lib);

//mach_port_t * port = [self getSpringBoardPort];
// open springboard lib
//void *lib = dlopen(SBSERVPATH, RTLD_LAZY);

// retrieve function SBFrontmostApplicationDisplayIdentifier
void *(*SBFrontmostApplicationDisplayIdentifier)(mach_port_t *port, char *result) =
dlsym(lib, "SBFrontmostApplicationDisplayIdentifier");

// reserve memory for name
char appId[256];
memset(appId, 0, sizeof(appId));

// retrieve front app name
SBFrontmostApplicationDisplayIdentifier(port, appId);

// close dynlib
dlclose(lib);
return [[NSString stringWithFormat:@"%s", appId] retain];
}

Also I show new framework FrontBoard anyone know should it will help to out of this problem?

like image 474
Bittu Avatar asked Oct 04 '14 07:10

Bittu


1 Answers

There's no way to do that anymore in iOS 8 since a vulnerability was discovered. A background app could attack though the frontmost app. More details here: http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-4361

like image 128
Profezy Avatar answered Oct 19 '22 09:10

Profezy