简体   繁体   English

将应用程序带到前台

[英]Bring App to foreground

Is there a way to bring my app to the foreground once a timer runs out? 一旦计时器用尽,是否可以将我的应用程序置于前台? This is for a kiosk-type app that'll display some information at various points during user's session. 这是针对信息亭类型的应用程序的,它将在用户会话期间的各个时间点显示一些信息。

This is for an app that will only be installed on our enterprise devices, thus not be submitted to Apple for approval. 这是针对仅会安装在我们企业设备上的应用程序,因此不会提交给Apple批准。 I am also opening to exploring jailbreak options. 我也愿意探讨越狱的选择。

I'd appreciate any help/tips you guys can provide. 谢谢您提供的任何帮助/提示。 Thanks. 谢谢。

Yes, you can technically use Xcode for jailbreak development (but you don't have to). 是的,您可以从技术上使用Xcode进行越狱开发(但不必这样做)。 If you want your app to be installed outside the normal sandbox, and in /Applications/ , then you'd build with Xcode without code signing, fake code sign (or use self-signed certificate), and then copy/install the app to your device, using scp or something similar (maybe have a script for this). 如果您希望将应用程序安装在常规沙箱外部,并且安装在/ Applications /中 ,则可以使用不带代码签名,伪造代码签名(或使用自签名证书)的Xcode 进行构建,然后将应用程序复制/安装到您的设备,使用scp或类似工具(可能有相应的脚本)。

You can google search on tools like "Theos", "Logos", or "iOSOpenDev", too. 您也可以在“ Theos”,“ Logos”或“ iOSOpenDev”等工具上进行Google搜索。 More here 这里更多

Also, see this page for information about fake code signing with Xcode . 另外, 有关使用Xcode进行伪代码签名的信息 ,请参见此页面

In terms of bringing an app to the foreground, there's at least a couple ways to handle that: 就将应用程序引入前台而言,至少有两种方法可以处理该问题:

One would be to use Cydia to install the (free) utility open . 一种方法是使用Cydia安装(免费)实用程序open With open , you can issue a command line call to open any app, by using its bundle ID (eg open com.mycompany.MyAppName ). 使用open ,您可以发出命令行调用,以使用其捆绑包ID(例如, open com.mycompany.MyAppName )打开任何应用程序。 If you want to do this programatically, issue that command within a system() call: 如果要以编程方式执行此操作,请在system()调用中发出该命令:

 #import <stdlib.h>

 int returnCode = system("/usr/bin/open com.mycompany.MyAppName");

Another alternative is to see this answer by @WrightsCS . 另一个选择是通过@WrightsCS查看此答案 Make sure to read the comments, too, about where this goes. 确保也阅读有关此内容的评论。


Update: in terms of putting your app into the background, you can kill your app completely with either exit(0) or [[UIApplication sharedApplication] terminateWithSuccess] . 更新: [[UIApplication sharedApplication] terminateWithSuccess]您的应用程序置于后台而言,您可以使用exit(0)[[UIApplication sharedApplication] terminateWithSuccess]完全杀死您的应用程序。 Or, see this answer for a solution to programmatically simulate a home button press , which will send the app to the background without killing it. 或者, 请参见此答案以编程方式模拟主屏幕按钮按下的解决方案,该解决方案会将应用程序发送到后台而不会杀死它。

You won't be able to use NSTimer , because timers don't fire while your app is in the background. 您将无法使用NSTimer ,因为在您的应用程序处于后台时计时器不会触发。 However, you can use GCD blocks to run your background work, and make the system() call with open to bring you back to the foreground. 但是,您可以使用GCD 来运行后台工作,并使用open进行system()调用,以使您回到前台。

See this answer, probably scrolling all the way to the bottom of his post 看到这个答案,可能一直滚动到帖子的底部

or look at this similar answer, which was actually posted at the bottom of the question 或看看这个类似的答案,它实际上是张贴在问题的底部

Jailbroken options for bringing your app to the foreground: 将您的应用程序置于前台的越狱选项:

Hook into SpringBoard using MobileSubstrate. 使用MobileSubstrate连接到SpringBoard。 You can find classes and methods with promising names, such as [SBApplicationIcon launch] and [SBApplication launch] . 您可以找到有前途名称的类和方法,例如[SBApplicationIcon launch][SBApplication launch] Another possibility is using SBSLaunchApplicationWithIdentifier() from the SpringBoardServices private framework. 另一种可能性是使用SpringBoardServices私有框架中的SBSLaunchApplicationWithIdentifier()

Options for suspending the app: 暂停应用的选项:

You most likely can do this again by using MobileSubstrate to make SpringBoard close a particular app for you. 您很可能可以通过使用MobileSubstrate使SpringBoard为您关闭特定应用程序来再次执行此操作。 Maybe you can simulate a home button click by calling [SBUIController handleMenuTap] or something similar. 也许您可以通过调用[SBUIController handleMenuTap]或类似方法来模拟主页按钮单击。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM