2016-06-10 67 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完成工作的情況。但這基本上是您唯一的其他潛在解決方案。