iOS 4 中的多任务感知应用程序和自定义 URL 方案
我正在尝试安全地实现 OAuth,如下所示: http:// fireeagle.yahoo.net/developer/documentation/oauth_best_practice#custom-url-osx。我似乎遇到了绊脚石,因为我无法弄清楚如何处理在后台启动我的应用程序的网址。
我已经注册了我的应用程序来处理 oauthtest。我已确认 oauthtest:// 和 oauthtest://callbacktest 都会启动我的应用程序,并在我的应用程序未在后台运行时按预期运行。
我正在实现
application:(UIApplication *) didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
当我的应用程序冷启动时成功调用它。我可以轻松地将 url 传递到我的应用程序。
但是,如果我的应用程序已经在后台运行,则既不会
application:(UIApplication *) didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
被调用,也不会
application:(UIApplication *) handleOpenURL:(NSURL *)url
被调用,并且我无法将参数作为 URL 的一部分传递给我的应用程序。
有谁知道如何通过自定义 url 方案获取传递到后台应用程序的参数?
我知道我可以通过禁用多任务处理来解决这个问题,但出于明显的原因我宁愿不这样做。提前致谢。
I'm trying to implement OAuth securely as detailed here: http://fireeagle.yahoo.net/developer/documentation/oauth_best_practice#custom-url-osx. I seem to have hit a stumbling block, as I am unable to figure out how to handle a url which launches my application when in the background.
I have registered my application to handle oauthtest. I have confirmed that oauthtest:// and oauthtest://callbacktest both launch my application and operate as intended when my application is not running in the background.
I am implementing
application:(UIApplication *) didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
which is successfully called when my application starts up cold. I can easily get the url passed to my application.
However, if my application is already running in the background, neither
application:(UIApplication *) didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
nor
application:(UIApplication *) handleOpenURL:(NSURL *)url
is called and I have no way of getting the parameters passed to my application as part of the URL.
Does anyone know how to get the parameters passed to a backgrounded application by a custom url scheme?
I am aware that I could work around this issue by disabling multitasking, but I would rather not do that for obvious reasons. Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
下面是一些似乎对我有用的示例代码,在 iOS4 中进行了测试:
如果我第一次启动应用程序,
didFinishLaunching:
会处理 URL。如果我随后将应用程序置于后台,返回 Safari,然后点击将应用程序带回前台的链接,则handleOpenURL:
会处理该 URL。祝你好运!Here's some sample code that seemed to work for me, tested in iOS4:
If I launch the application for the first time,
didFinishLaunching:
handles the URL. If I then put the app in the background, go back to Safari, and tap a link that brings the app back into the foreground, thenhandleOpenURL:
takes care of the URL. Good luck!