iOS 6 Runtime headers 使用其包标识符打开应用程序的方法[Non-jailbreak]
iOS 6 Runtime headers method to open an application using its bundle identifier[Non-jailbreak]
我想使用 iOS 6 运行时 headers 方法通过其包标识符以编程方式打开应用程序。我已经在 iOS 7 和 8 中完成了此操作,但我在 iOS 6 中找不到任何合适的方法。请指导我该怎么做。请记住,我正在为企业应用程序实现此功能。
iOS7 和 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
你可以找到一些URL方案的列表here or here
对于其他应用程序,您必须提取 .ipa。这是一种方法(来自 that SO answer):
So I went to iTunes on my mac and looked in my App Library for the "APP IN QUESTION".
I then: • Right-Clicked on the "APP IN QUESTION" app and selected “Show in Finder”
• then duplicated the "APP IN QUESTION" .ipa file
• Then I renamed the .ipa file to end in .zip instead (saying, yes make it a .zip if necessary)
• Then I unzipped it to a folder
• I opened the Payload Folder
• I right-clicked the “"APP IN QUESTION".app” and selected “Show Package Contents”
• I opened up the “Info.plist” file in a text editor like the free TextWrangler.app
• I searched for “URL” and found the following:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>app-in-question</string>
<string>sslapp-in-question</string>
</array>
</dict>
</array>
I was then able to successfully go to Safari and type in: app-in-question:// and sslapp-in-question:// and was prompted if I wanted to launch the App in Question.
编辑:
这应该有效
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);
我想使用 iOS 6 运行时 headers 方法通过其包标识符以编程方式打开应用程序。我已经在 iOS 7 和 8 中完成了此操作,但我在 iOS 6 中找不到任何合适的方法。请指导我该怎么做。请记住,我正在为企业应用程序实现此功能。
iOS7 和 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
你可以找到一些URL方案的列表here or here 对于其他应用程序,您必须提取 .ipa。这是一种方法(来自 that SO answer):
So I went to iTunes on my mac and looked in my App Library for the "APP IN QUESTION".
I then: • Right-Clicked on the "APP IN QUESTION" app and selected “Show in Finder”
• then duplicated the "APP IN QUESTION" .ipa file
• Then I renamed the .ipa file to end in .zip instead (saying, yes make it a .zip if necessary)
• Then I unzipped it to a folder
• I opened the Payload Folder
• I right-clicked the “"APP IN QUESTION".app” and selected “Show Package Contents”
• I opened up the “Info.plist” file in a text editor like the free TextWrangler.app
• I searched for “URL” and found the following:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>app-in-question</string>
<string>sslapp-in-question</string>
</array>
</dict>
</array>
I was then able to successfully go to Safari and type in: app-in-question:// and sslapp-in-question:// and was prompted if I wanted to launch the App in Question.
编辑:
这应该有效
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);