iOS 6运行时间标头方法使用其包标识符打开应用程序

我想通过使用iOS 6运行时标头方法通过其包标识符以编程方式打开应用程序。 我已经在iOS 7和iOS 8中完成了这个工作,但在iOS 6中找不到任何合适的方法。请指导我如何做到这一点。 请记住,我正在为企业应用程序实现此function。

iOS 7和8中的工作代码

if ([self checkOSVersion] >= 7) { Class LSApplicationWorkspace_class = objc_getClass("LSApplicationWorkspace"); NSObject* workspace = [LSApplicationWorkspace_class performSelector:@selector(defaultWorkspace)]; BOOL result = [[workspace performSelector:@selector(openApplicationWithBundleID:) withObject:appIdentifier] boolValue]; } 

我不认为你可以做到这一点,而不使用URL计划

 [[UIApplication sharedApplication] openUrl:[NSURL urlWithString:@"yourUrlScheme://"]]; 

缺点:您需要提前注册,或了解应用程序注册的URLscheme

你可以在这里或这里find一些URL Scheme的列表对于其他应用程序,你将不得不提取.ipa。 这是一个方法来做到这一点(从这个答案 ):

所以我去了我的Mac上的iTunes,并在我的应用程序库中查看“APP IN QUESTION”。

然后我:•右键单击“APP IN QUESTION”应用程序,然后select“在Finder中显示”

然后复制“APP IN QUESTION”.ipa文件

然后,我将.ipa文件重命名为以.zip结尾(如果需要,请将它设为.zip)

然后我将它解压缩到一个文件夹

•我打开了有效负载文件夹

•我右键单击“”问题应用程序“.app”,然后select“显示包装内容”

•我在文​​本编辑器(如免费的TextWrangler.app)中打开了“Info.plist”文件

•我search“URL”,发现以下内容:

 <key>CFBundleURLTypes</key> <array> <dict> <key>CFBundleURLSchemes</key> <array> <string>app-in-question</string> <string>sslapp-in-question</string> </array> </dict> </array> 

然后,我可以成功地进入Safari并input:app-in-question://和sslapp-in-question://提示是否要在问题中启动应用程序。

编辑:

这应该工作

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