1
我给自己定一个URL处理器 “很快” 当我的应用程序是启动:在 - (空)的applicationDidFinishLaunching:(NSNotification *):OS X URL处理程序,但启动应用程序时?
[[NSAppleEventManager sharedAppleEventManager] setEventHandler:self andSelector:@selector(getUrl:withReplyEvent:) forEventClass:kInternetEventClass andEventID:kAEGetURL];
LSSetDefaultHandlerForURLScheme((CFStringRef)@"myScheme", (__bridge CFStringRef)[[NSBundle mainBundle] bundleIdentifier]);
它能正常工作,使用getURL:withReplyEvent:被称为每当带有myScheme://方案的URL被打开时!
但是,如果我的应用程序是没有运行(退出),如果在Safari我打开一个URL,例如myScheme:// some_valuable_info行动= DoSomething的,它推出我的应用程序......但我怎么知道我已被推出通过URL处理程序?我如何获取触发我的应用程序启动的URL?
它应该调用getUrl:withReplyEvent :,不是吗?否则我不明白一个问题。 –
是的,但它没有。看到我的答案如下:我没有很快注册eventHandler! – Altimac