I need to have a demo app that will wake up itself from background on timer event. Is it possible without jailbreak by using private API? Tried this code:
void* sbServices = dlopen(SBSERVPATH, RTLD_LAZY);
int (*SBSLaunchApplicationWithIdentifier)(CFStringRef identifier, Boolean suspended) = dlsym(sbServices, "SBSLaunchApplicationWithIdentifier");
int result;
result = SBSLaunchApplicationWithIdentifier(CFSTR("com.my.app"), false);
dlclose(sbServices);
Didn't worked
Finally I found a solution using private api. Here is an example code launching custom app every 10 seconds
@interface PrivateApi_LSApplicationWorkspace
- (bool)openApplicationWithBundleID:(id)arg1;
@end
@implementation ViewController {
PrivateApi_LSApplicationWorkspace* _workspace;
}
- (void)viewDidLoad {
[super viewDidLoad];
_workspace = [NSClassFromString(@"LSApplicationWorkspace") new];
NSTimer *timer = [NSTimer timerWithTimeInterval:10.0 repeats:YES block:^(NSTimer * _Nonnull timer) {
[self openAppWithBundleIdentifier:@"com.app.my"];
}];
[[NSRunLoop mainRunLoop] addTimer:timer forMode:NSDefaultRunLoopMode];
}
- (BOOL)openAppWithBundleIdentifier:(NSString *)bundleIdentifier {
return (BOOL)[_workspace openApplicationWithBundleID:bundleIdentifier];
}
@end