0

How can I get notifications count of another app into my app by using SpringboardServices and SBSPushStore? I'm trying to show notification count taken from whatsapp into my app so I was searching around and one thing is for sure that it is possible but I didn't find any approbate way on how to do it.
Here is the question which answers it but I didn't get it. How to do it? Can someone please share the step by step procedure.

Based on the question I was able to find the code which can actually lock you iphone using SpringboardServices but I don't know how to use it for SBSPushStore?

void *SpringBoardServices = dlopen("/System/Library/PrivateFrameworks/SpringBoardServices.framework/SpringBoardServices", RTLD_LAZY);
    NSParameterAssert(SpringBoardServices);
    mach_port_t (*SBSSpringBoardServerPort)() = dlsym(SpringBoardServices, "SBSSpringBoardServerPort");
    NSParameterAssert(SBSSpringBoardServerPort);
    SpringBoardServicesReturn (*SBSLockDevice)(mach_port_t port) = dlsym(SpringBoardServices, "SBSLockDevice");
    NSParameterAssert(SBSLockDevice);
    mach_port_t sbsMachPort = SBSSpringBoardServerPort();
    SBSLockDevice(sbsMachPort);
    dlclose(SpringBoardServices);
Community
  • 1
  • 1
Chaudhry Talha
  • 7,231
  • 11
  • 67
  • 116
  • That answer will only work on a jailbroken device and can't be used in an App Store app. Is that what you want? – Paulw11 Aug 09 '16 at 12:20
  • @Paulw11 It's okay I just have to show the demo. This app is not going on the store. So kindly share the step by step procedure as I'm a naive developer. – Chaudhry Talha Aug 09 '16 at 12:24
  • @Paulw11 here I found the SBSPushStore https://github.com/MP0w/iOS-Headers/tree/master/iOS5.0/PrivateFrameworks/SpringBoardServices – Chaudhry Talha Aug 09 '16 at 12:58

1 Answers1

0

The answer to that linked question you commented on implies that you don't need any framework, as long as your device is jailbroken. You simply load the plist file located at /var/mobile/Library/SpringBoard/applicationState.plist. The format of that answer is a bit broken, but I assume the > are meant as indicators to explain the inner structure of the file (i.e. key values).

So from that I assume it's a dictionary, you can load it by

NSDictionary *plistFile = [NSDictionary dictionaryWithContentsOfFile:@"/var/mobile/Library/SpringBoard/applicationState.plist"];
NSDictionary *entryForYourApp = plistFile[@"com.app.identifier"]; // obviously you have to use the identifier of whatever app you wanna check
NSInteger badgeCount = entryForYourApp[@"SBApplicationBadgeKey"];

You probably want to inspect the file yourself first (so set a debug point) and make sure its structure is like I assumed, the types are correct and so forth (not to mention it exists, Apple sometimes changes stuff like that and the other question is already several years old).

In general be aware that you can only do that, as said, on a jailbroken device. Otherwise your application simply doesn't have reading access to the path /var/mobile/Library/SpringBoard/applicationState.plist. Or to anything outside its sandbox, for that matter.

Gero
  • 4,394
  • 20
  • 36