15

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?

halfer
  • 19,824
  • 17
  • 99
  • 186
Bittu
  • 371
  • 4
  • 17
  • 1
    i have same problem , i am not getting solution yet – Birju Oct 04 '14 at 07:38
  • 2
    May be Apple have disabled this from iOS 8 onwards – Anand Oct 04 '14 at 07:40
  • 1
    Looks like FrontBoard is a private framework. That won't work for app store apps. You could use it for apps for your own use, or for jailbroken apps, but you're going to get rejected by the app store if you try to use private framework like that. – Duncan C Jan 01 '15 at 17:21
  • 4
    see http://stackoverflow.com/questions/26161001/ios-8-how-to-determine-the-foreground-app-as-well-as-get-list-of-running-apps it is considered a vulnerability and is disabled in iOS 8. – Michael Latta Feb 24 '15 at 18:35
  • Hopes there is a workaround for iOS8 & iOS9 – tounaobun Aug 26 '15 at 13:20

1 Answers1

1

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

Jorge
  • 1,066
  • 8
  • 16