Today App Extension Widget Tap To Open Containing App

Solution 1:

EDIT: Ok, just a little correction here. I got it working with placing a button over the label just like suggested above and the following code:

- (IBAction) goToApp: (id)sender { 
    NSURL *url = [NSURL URLWithString:@"floblog://"];
    [self.extensionContext openURL:url completionHandler:nil]; 
  }

I linked it to a "Touch Up Inside" event. However, this also causes the app to launch when the user scrolls the Today view.

=======================================

I ran into the same issue. However, it seems that there is no solution for now since the release notes for the first beta of iOS 8 mention:

Known Issues: openURL does not work from an extension.

So I guess we will at least have to wait until beta 2.

Solution 2:

Swift 2 version, according to Apple Doc

extensionContext?.openURL(NSURL(string: "foo://")!, completionHandler: nil)

Swift 3 version

extensionContext?.open(URL(string: "foo://")! , completionHandler: nil)

And don't forget to add Custom URL Schemes into Info.plist

enter image description here

Solution 3:

The answer by @sunseeker is the good one but it is "hidden" in the comments. And as the accepted answer says that this isn't possible, it may mislead visitors.

this code works:

- (IBAction)launchHostingApp:(id)sender
{
  NSURL *pjURL = [NSURL URLWithString:@"hostingapp://home"];
  [self.extensionContext openURL:pjURL completionHandler:nil];
}

I'm using Xcode 6.0 (6A215l) with Yosemite Beta 1.

And like Apple says in Handling Commons Scenarios :

An extension doesn’t directly tell its containing app to open; instead, it uses the openURL:completionHandler: method of NSExtensionContext to tell the system to open its containing app. When an extension uses this method to open a URL, the system validates the request before fulfilling it.