3

我知道其他应用程序可以通过 URL 架构从您的应用程序调用。但并非所有应用程序都注册了架构 URL。那么如何启动该应用程序呢?我正在为 iphone jaibroken 开发。

4

4 回答 4

6

您可以通过多种方式使用 Bundle ID 启动应用程序。

SB应用

SBApplication *app = [[objc_getClass("SBApplicationController") sharedInstance] applicationWithDisplayIdentifier:@"com.wrightscs.someapp"];
[[objc_getClass("SBUIController") sharedInstance] activateApplicationFromSwitcher: app];

SBApplicationController

SBUIController *uicontroller = (SBUIController *)[%c(SBUIController) sharedInstance];
SBApplicationController *appcontroller = (SBApplicationController *)[%c(SBApplicationController) sharedInstance];

if ([[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)])
{
    [uicontroller activateApplicationFromSwitcher:[[appcontroller applicationsWithBundleIdentifier:bundleID] objectAtIndex:0]];
}
else
{
    // doesn't work outside of Springboard
    [uicontroller activateApplicationAnimated:[[appcontroller applicationsWithBundleIdentifier:bundleID] objectAtIndex:0]];
}

我在 4.x 中使用了另一种方法,SBUIController但在 5.0 中停止工作,所以我不打算发布它。

于 2012-07-27T18:47:03.890 回答
2

我用这种方式:

void* sbServices = dlopen("/System/Library/PrivateFrameworks/SpringBoardServices.framework/SpringBoardServices", RTLD_LAZY);
int (*SBSLaunchApplicationWithIdentifier)(CFStringRef identifier, Boolean suspended) = dlsym(sbServices, "SBSLaunchApplicationWithIdentifier");
int result = SBSLaunchApplicationWithIdentifier((CFStringRef)bundleId, false);
dlclose(sbServices);

您需要授予您的应用程序的权利:

 <key>com.apple.springboard.launchapplications</key>
 <true/>

它可以在 iOS 6 上运行。

于 2013-03-27T03:30:12.270 回答
2

据我所知,只有私有 api 可以做到这一点。第一的

@interface PrivateApi_LSApplicationWorkspace
- (bool)openApplicationWithBundleID:(id)arg1;
@end

然后使用它

PrivateApi_LSApplicationWorkspace* _workspace;
_workspace = [NSClassFromString(@"LSApplicationWorkspace") new];
[_workspace openApplicationWithBundleID:bundleIdentifier];

您可以查看https://github.com/wujianguo/iOSAppsInfo

于 2015-11-16T02:48:08.073 回答
0

我刚刚测试过:在 iOS 9.3.5 和 11.2 中工作,而且这种方法不需要任何包含或动态加载库。完全依赖 obj-c 运行时。而且这种方法不需要越狱设备,可以使用 xcode 设备和带有配置文件的免费开发人员帐户来完成。不要以为它会通过 App store 审核流程,但可以成功用于企业或 ad-hoc 分发等。

id wrkS;
wrkS = [NSClassFromString(@"LSApplicationWorkspace")  performSelector:@selector(defaultWorkspace)];
[wrkS performSelector:@selector(openApplicationWithBundleID:) withObject:@"com.apple.reminders"];
于 2018-02-14T10:31:08.640 回答