我需要一个演示应用程序,它将从计时器事件的后台唤醒。是否可以通过使用私有API进行越狱?试过这段代码:
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);
没有工作
答案 0 :(得分:0)
最后我找到了使用私有api的解决方案。以下是每10秒启动自定义应用的示例代码
@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