NSExtensionContext openURL not working on Mac OS X Today Widget

No matter what I do, the following code simply returns β€œSuccess: 0” (i.e. it will not start the hosting application):

  NSURL *url = [NSURL URLWithString:@"myapp://launch"];
  [[self extensionContext] openURL:url completionHandler:^(BOOL success) {
    NSLog(@"Success? %i", success);
  }];

If I try to launch the myapp: // URL directly in Safari, it works and launches my application. However, Today Widget refuses to launch it. It is isolated, and I also turned on Outbound connectivity features, but no luck. What do I need to do to make it work?

+3
source share
1 answer

, , NSWorkspace. , , , :

  if (![[NSWorkspace sharedWorkspace] openURL: url]) {
    [[self extensionContext] openURL:url completionHandler:^(BOOL success) {
      NSLog(@"Success? %i", success);
    }];
  } else {
    NSLog(@"Success!");
  }
+5

All Articles