2016-06-10 70 views
0

我处理自定义URL方案像这样AppDelegate.m自定义URL方案,而不必应用前面

-(void)applicationWillFinishLaunching:(NSNotification *)aNotification 
{ 
    NSAppleEventManager *appleEventManager = [NSAppleEventManager sharedAppleEventManager]; 
    [appleEventManager setEventHandler:self 
          andSelector:@selector(handleGetURLEvent:withReplyEvent:) 
         forEventClass:kInternetEventClass andEventID:kAEGetURL]; 
} 

- (void)handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent 
{ 
    NSString * URL = [[event paramDescriptorForKeyword:keyDirectObject] stringValue]; 
    //Do my work with URL 
} 

这是工作,但有可能我每次打电话的时候不要把前面的应用定制方案?

回答

0

不幸的是,在您的应用程序未到达前台的情况下处理URL是不可能的。

根据你在做什么,这可能是你可以用App Extension完成工作的情况。但这基本上是您唯一的其他潜在解决方案。