ios - 如何在 iOS 上通过 bundle id 打开应用程序

标签 ios jailbreak

刚才,我在Xcode6.3.1上创建了一个基于Single View Application的项目,然后在Main.storyboard上创建了一个按钮。触摸按钮时的代码是这样的:

NSString * bundleId = @"com.apple.iBooks";
void* sbServices = dlopen("/System/Library/PrivateFrameworks/SpringBoardServices.framework/SpringBoardServices", RTLD_LAZY);
int (*SBSLaunchApplicationWithIdentifier)(CFStringRef identifier, Boolean suspended) = dlsym(sbServices, "SBSLaunchApplicationWithIdentifier");
const char *strBundleId = [bundleId cStringUsingEncoding:NSUTF8StringEncoding];
int result = SBSLaunchApplicationWithIdentifier((__bridge CFStringRef)bundleId, NO);
dlclose(sbServices);

但是没有用。 然后我喜欢这个网站告诉我,Launch other application without URL schema in iphone? 它也没有用。请帮我。 我的设备是iPhone4s,iOS 7.1.2,越狱。

最佳答案

* 对于越狱,您可以继续执行此操作 *

有一种称为 URL 方案 的机制,可用于从应用程序内部打开应用程序。但为此,您需要在 plist 文件中进行正确的 url 方案设置。我强烈感觉到您没有考虑这个选项。

* 还有另一种严格不推荐的方法(JAILBREAK PHONES 除外)API 是私有(private)的 *,但您可以在开发模式下尝试并享受。

  • openApplicationWithBundleID:使用包标识符打开应用程序。
  • - (NSArray*)allInstalledApplications;:这将列出您设备上所有已安装的应用程序。

如果你想看一个有趣的演示,请 run this app在您的手机中并查看 Apple Watch 样式、跳板,其中列出了所有应用程序并且可以在点击时启动。

希望能更好地了解私有(private) api 的用法。

关于ios - 如何在 iOS 上通过 bundle id 打开应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30476982/

相关文章:

iOS:CGImageCreateWith[PNG 或 JPEG]DataProvider 导致段错误

iphone - 在 UILabel 的一部分上点击手势

iphone - remoteControlReceivedWithEvent 未在 appDelegate 中调用

ios - 最大化 TitleView 的宽度

ipad - 在 iPhone SDK 上扫描 Wifi 网络

iphone - 是否可以检查设备是否越狱?

iOS 如何使用私有(private) API 中的 UIApplication launchApplicationWithIdentifier?

ios - AudioBufferList 在 Swift 中分配

ios - 通过企业计划将应用程序发布到 Apple App Store

ios - 如何在微调中使用 OpenEars?