不后台时适用于iOS App的自定义URL方案

问题描述:

我为我的应用程序设置了自定义的深层链接iOS URL方案,我在

I have set up a custom deep-linking iOS URL scheme for my app, and I listen for it in

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {

我解析URL并使用NSNotificationCenter(以URL为对象)向适当的类发送通知以处理URL.

I parse the URL and send a notification using NSNotificationCenter, with the URL as the object, to the appropriate class to handle the URL.

当应用程序后台"运行时,这一切都很好,但是当应用程序由于多任务处理而完全关闭时,通知似乎永远不会发送(或接收).当应用程序不在后台运行时,我是否会丢失有关通知过程的信息?还有另一种方式传递URL中的信息吗?还是至少有一种方法可以判断该应用程序是否脱离后台运行或是否是全新启动的?

This all works great when the app is "backgrounded" but when the app is fully closed out of multitasking, it seems like the notification never gets sent (or received). Am I missing something about the process of notifications when the app isn't in backgrounding? Is there another way to pass along the information from the URL? Or is there at least a way to tell if the app is coming out of backgrounding or if it is a fresh launch?

谢谢!

您应该检查传递给applicationDidFinishLuanching:withOptions:launchOptions词典.

You should check the launchOptions dictionary that is passed into applicationDidFinishLuanching:withOptions:.

有关选项字典中包含的内容的完整详细信息: http://developer.apple.com/library/ios/#documentation/uikit/reference/UIApplicationDelegate_Protocol/Reference/Reference.html

For full details on what is included in the options dictionary: http://developer.apple.com/library/ios/#documentation/uikit/reference/UIApplicationDelegate_Protocol/Reference/Reference.html