Make NSApplication's -openURL: available to extensions (with restrictions)

Originator:craig.hockenberry
Number:rdar://18446584 Date Originated:
Status:Duplicate/17351373 Resolved:
Product:iOS SDK Product Version:8.0
Classification:Enhancement Reproducible:N/A
 
Currently, NSApplication's -openURL: method is off limits to extensions (and is marked accordingly as NS_EXTENSION_UNAVAILABLE_IOS).

This accomplishes a reasonable goal of preventing extensions becoming app launchers or web URL shortcuts. There is no question that would be a crappy user experience.

But this also prevents a reasonable use case: giving a user an easy back to the app that hosts the extension. If someone has the CooolEffects Photos Extension installed, the only way to get this user back to the app is with a bunch of instructions:

1. Hit the home button
2. Scroll around on your home screen until you find CooolEffects
3. Launch CooolEffects
4. Go to the help screen

Chances are that the host app isn't near the first page on the homescreen, either.

What I'd like to see is a restriction on the URLs that can be opened from the extension: only allow URL schemes supported by the host app.

For example, CooolEffects could add the following to its Info.plist:

	<array>
		<dict>
			<key>CFBundleURLName</key>
			<string>COM.CHOCKLOCK.CoolEffects</string>
			<key>CFBundleURLSchemes</key>
			<array>
				<string>coooleffects</string>
			</array>
		</dict>
	</array>

Then the extension could do something like this:

	NSURL *URL = [NSURL URLWithString:@"coooleffects:///help&page=1"];
	[[UIApplication hostApplication] openURL:URL];

The extension can then parse the NSURL -query or -fragment as it sees fit. 

Of course, some butthead developer is going to come around and do something like this:

	[NSURL URLWithString:@"coooleffects:///relay=http://playboy.com"]
	
or:

	[NSURL URLWithString:@"coooleffects:///relay=anotherapp:///whatever"]

But App Review can easily check that an app includes both a URL scheme and extension, and then give it more scrutiny during review.

Steps to Reproduce:
N/A

Expected Results:
N/A

Actual Results:
N/A

Version:
iOS 8.0

Notes:


Configuration:
iPhone 6

------

Alternatively, use NSExtensionContext to create a "one way street" back to the application that hosts the extension. The use cases I'm envisioning are for things like help and settings: there's no need to have a completion handler with -openURL or even a URL for that matter. So the extension could do something like this:

	NSExtensionContext *extensionContext = myViewController.extensionContext;
	[extensionContext openWithParameters:@{ @foo : @123, @bar : @999 }];
	
Which would open the application that supplies the extension with:

	- (BOOL)application:(UIApplication *)application openFromExtensionWithParameters:(id)parameters
	{
	}

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!