的UIApplication的OpenURL背景 [英] UIApplication openURL background

查看:90
本文介绍了的UIApplication的OpenURL背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的iOS 4的应用程序,我需要从后台打开一个URL,从用户指定的时间。然而,由于某种原因,我无法从背景由于某些原因发射的URL。这里是我的code打开一个网址:

In my iOS 4 application, I need to open a URL from the background, at a time specified from the user. However, for some reason, I cannot launch a URL from the background for some reason. Here is my code for opening a URL:

if (![[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.stackoverflow.com"]])
{
     // the URL wasn't opened. we will ignore this for now.
}

这code是所有正在从先前创建一个守护线程启动。我已经测试在模拟器上这个code和URL没有打开,方法返回由于某些原因,但是当我再次打开我的应用程序(通过快速应用程序切换),它打开的URL。是否有某种方式,我可以让我的应用程序在这一点(不是通过本地通知)再来到前台,这样的URL可能会打开,或者这是一个错误或无证功能。此外,如果有另一种方式来打开URL,即会在后台工作,这将是有益的了。

That code is all being launched from a daemon thread created earlier. I have tested this code on the simulator, and the URL is not opened, and the method returns YES for some reason, but when I open my application again (via fast-app-switching) it opens the URL. Is there some way that I can make my application come to the foreground again at this point (not via a local notification) so that the URL may open, or is this a bug or undocumented feature. Also, if there is another way to open the URL, that will work in the background, that would be helpful too.

推荐答案

我相信我已经找到它(不能在模拟器工作,因为它传递的命令对MAC的终端,因为没有为没有命令行模拟器)。使用此:

I believe I have found it (doesn't work on simulator, because it passes commands to the terminal on the mac, as there is no command line for the simulator). Use this:

system([[NSString stringWithFormat:@"uiopen \"%@\"", myUrlToOpen] UTF8String]);

这将通过命令 uiopen (通过越狱找到)到设备,迫使它打开URL。我希望这可以帮助其他人在我的位置上。

That will pass the command uiopen (found via jailbreak) to the device, forcing it to open that URL. I hope this helps others in my position.

这篇关于的UIApplication的OpenURL背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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