如何在iOS上通过捆绑包ID打开应用程序 [英] how to open an app by bundle id on iOS

查看:144
本文介绍了如何在iOS上通过捆绑包ID打开应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Just now , I create a project based on Single View Application on Xcode6.3.1, then I create a button on Main.storyboard. The code is like this when the button touched:

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);

但它不起作用。
然后我喜欢这个网站告诉我,启动其他应用程序在iphone中没有URL架构?
它也不起作用。请帮帮我。
我的设备是iPhone4s,iOS 7.1.2,越狱。

But it did not work. Then I do like this site tell me , Launch other application without URL schema in iphone? It did not work,either. Please help me. My device is iPhone4s, iOS 7.1.2, jailbroken.

推荐答案

*对于越狱,你可以继续这个*

有一种机制称为 URL scheme ,可用于从您的应用内打开应用。但为此你需要在你的plist文件中做正确的url schemens setUp。我强烈认为你没有看这个选项。

There is a mechanism known as URL scheme, which can be used to open app from inside your app. but for that you need to do the proper url schemens setUp in your plist file. I strongly feel that you are not looking at this option.

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

* There is another way strictly not recommended ( except JAILBREAK PHONES) the API is private *, but you can do a try & enjoy in development mode.


  • openApplicationWithBundleID :使用包标识符打开应用程序。

  • - (NSArray *)allInstalledApplications; :这将列出您设备上已安装的所有应用程序。

  • openApplicationWithBundleID : To open the app using bundle identifier.
  • - (NSArray*)allInstalledApplications; : This will list you all the installed application on your device.

如果你想看到一个有趣的演示,请在您的手机中运行此应用查看 Apple Watch 风格,弹簧板,列出所有应用程序&可以随时启动。

If you want to see an interesting demo it this, kindly run this app in your phone & see the Apple Watch style, spring board, with all apps listed & can be launched on tap.

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

Hope that gives the better idea of the private api usage.

这篇关于如何在iOS上通过捆绑包ID打开应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆