在iphone中启动其他没有URL架构的应用程序?
我知道其他应用程序可以通过URL模式从应用程序调用。 但并非所有的应用程序都是注册模式URL。 那么我怎么能启动那个应用程序? 我正在开发的iPhone jaibroken。
我用这种方式:
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上运行。
有几种方法可以使用Bundle ID启动应用程序。
SBApplication
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中停止工作,所以我不打算发布它。
据我所知,只有私人API可以做到这一点。 第一
@interface PrivateApi_LSApplicationWorkspace - (bool)openApplicationWithBundleID:(id)arg1; @end
然后使用它
PrivateApi_LSApplicationWorkspace* _workspace; _workspace = [NSClassFromString(@"LSApplicationWorkspace") new]; [_workspace openApplicationWithBundleID:bundleIdentifier];